Browse Source

Add usage description, --bugs

master
Nico Schottelius 3 years ago
parent
commit
d28748618d
  1. 6
      README.md
  2. 12
      ungleich_ssh_key.py

6
README.md

@ -49,3 +49,9 @@ Creating a new account object:
ungleich account --create-user <username> --name <firstname> --lastname <lastname> --email <email>
```
### Usage: SSH Key
```
ungleich sshkey --key raul.ascencio --host dev.raul.ungleich.cloud
```

12
ungleich_ssh_key.py

@ -22,8 +22,8 @@ class SSHKey(object):
required=True)
self.parser['sshkey'].add_argument('--key-dir',
help='Directory holding keys',
default=os.path.join(os.environ['HOME'], "vcs/ungleich-ssh-keys/"),
required=false)
default=os.path.join(os.environ['HOME'], "vcs/ungleich-ssh-keys/current"),
required=False)
self.parser['sshkey'].add_argument('--host',
help='Host to use',
required=True)
@ -38,12 +38,14 @@ class SSHKey(object):
print("Not yet supported to delete, sorry :-)")
sys.exit(1)
keyfile = os.path.join(args.keydir, "{}.pub".format(args.key))
keyfile = os.path.join(args.key_dir, "{}.pub".format(args.key))
if not os.path.exists(keyfile):
print("Key for {} does not exist in {}. Aborting".format(args.key, args.keydir))
print("Key for {} does not exist in {}. Aborting".format(args.key, args.key_dir))
sys.exit(1)
cmd = 'cat {} | ssh {} "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"'.format(keyfile, args.host)
cmd = 'cat {} | ssh {}@{} "mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"'.format(keyfile,
args.user,
args.host)
subprocess.run(cmd, shell=True)

Loading…
Cancel
Save