diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-05-09 15:25:24 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-05-09 15:25:24 +0000 |
commit | 2fd6e99f2aa08f42b4c71fe5c7594c4bc72b558b (patch) | |
tree | 656cc507b41be67c24d32cf67f76e1e3f7628adb /morphlib/exts | |
parent | 55dd54adbb240a665bc98f6ce0bec40f614a9138 (diff) | |
parent | cf1cdf88718dda1ca2c98469a649bae168d4793f (diff) | |
download | morph-2fd6e99f2aa08f42b4c71fe5c7594c4bc72b558b.tar.gz |
Merge branch 'support-known-hosts' of git://git.baserock.org/baserock/baserock/morph
A column width error was fixed up in the merge.
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-x | morphlib/exts/ssh.configure | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/morphlib/exts/ssh.configure b/morphlib/exts/ssh.configure index 6012f298..29a3589a 100755 --- a/morphlib/exts/ssh.configure +++ b/morphlib/exts/ssh.configure @@ -24,6 +24,7 @@ import os import sys import shutil import glob +import re import logging import morphlib @@ -63,6 +64,21 @@ class SshConfigurationExtension(cliapp.Application): if authkey: self.check_dir(dest, mode) self.comb_auth_key(authkey, dest) + + # Fills the known_hosts file + key = 'root_known_host_*_key.pub' + src = os.path.join(os.environ['SSH_KEY_DIR'], key) + known_hosts_keys = glob.glob(src) + known_hosts_path = os.path.join(args[0], 'root/.ssh/known_hosts') + known_hosts_file = open(known_hosts_path, "a") + for filename in known_hosts_keys: + hostname = re.search('root_known_host_(.+?)_key.pub', + filename).group(1) + known_hosts_file.write(hostname + " ") + f = open(filename, "r") + known_hosts_file.write(f.read()) + f.close() + known_hosts_file.close() else: self.status(msg="No SSH key directory found.") pass |