tildetown-admin/scripts/create_keyfile.py

18 lines
430 B
Python
Raw Normal View History

2017-02-16 07:25:39 +00:00
#!/usr/bin/env python3
2017-02-16 08:49:26 +00:00
"""this script allows django to add public keys for a user. it's in its own
script so that a specific command can be added to the ttadmin user's sudoers
file."""
2017-02-16 07:25:39 +00:00
import sys
KEYFILE_PATH = '/home/{}/.ssh/authorized_keys2'
def main(argv):
username = argv[1]
with open(KEYFILE_PATH.format(username), 'w') as f:
f.write(sys.stdin.read())
if __name__ == '__main__':
exit(main(sys.argv))