diff options
author | Richard Holland <richard.holland@codethink.co.uk> | 2013-04-04 17:09:36 +0000 |
---|---|---|
committer | Richard Holland <richard.holland@codethink.co.uk> | 2013-04-04 17:09:36 +0000 |
commit | 6adc04c3697c6845bf1da6970fefdfd4f1548b7b (patch) | |
tree | 72982a448b586ef18946380a8295d3e782bac761 | |
parent | 9bd472aed9ce2098a2aceec6b404a25cb0548202 (diff) | |
download | morph-6adc04c3697c6845bf1da6970fefdfd4f1548b7b.tar.gz |
Fixed error SSH configuration extension
Fixed error in function copy_rename_key that tried to place key in non
existent directory. Required use of os.path.basename to leave name of
key and remove rest of path.
-rwxr-xr-x | morphlib/exts/ssh.configure | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/morphlib/exts/ssh.configure b/morphlib/exts/ssh.configure index 8650b4f5..75b46b11 100755 --- a/morphlib/exts/ssh.configure +++ b/morphlib/exts/ssh.configure @@ -59,7 +59,7 @@ class SshConfigurationExtension(cliapp.Application): if roothost or roothostpub: self.check_dir(dest, mode) self.copy_rename_keys(roothost, - roothostpub, dest, 'id_', [15, 4]) + roothostpub, dest, 'id_', [5, 4]) if authkey: self.check_dir(dest, mode) self.comb_auth_key(authkey, dest) @@ -101,16 +101,18 @@ class SshConfigurationExtension(cliapp.Application): def copy_rename_keys(self, keys, pubkeys, dest, new, snip): '''Copies SSH keys to new VM and renames them''' - + st, fi = snip for key in keys: - s = len(key) - nw_dst = os.path.join(dest, new + key[st:s-fi]) + base = os.path.basename(key) + s = len(base) + nw_dst = os.path.join(dest, new + base[st:s-fi]) shutil.copy(key, nw_dst) os.chmod(nw_dst, 0600) for key in pubkeys: - s = len(key) - nw_dst = os.path.join(dest, new + key[st:s-fi-4]) + base = os.path.basename(key) + s = len(base) + nw_dst = os.path.join(dest, new + base[st:s-fi-4]) shutil.copy(key, nw_dst + '.pub') os.chmod(nw_dst, 0644) |