summaryrefslogtreecommitdiff
path: root/ec2init/CloudConfig.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-01-22 14:43:36 -0500
committerScott Moser <smoser@ubuntu.com>2010-01-22 14:43:36 -0500
commit8c66ea2f37d34c26ee2f6013aa98605c213d0e02 (patch)
treeac7f58cb56bfbac6fafcd577e5b8f54ea82e1078 /ec2init/CloudConfig.py
parent3c0b9591b5203e60ac3cdda030b6eecbae27e938 (diff)
downloadvyos-cloud-init-8c66ea2f37d34c26ee2f6013aa98605c213d0e02.tar.gz
vyos-cloud-init-8c66ea2f37d34c26ee2f6013aa98605c213d0e02.zip
Add support for ssh keys in cloud-config. move write_file to util.
---- #cloud-config apt_update: true ssh_keys: rsa_private: | -----BEGIN RSA PRIVATE KEY----- MIIBxwIBAAJhAKD0YSHy73nUgysO13XsJmd4fHiFyQ+00R7VVu2iV9Qcon2LZS/x ... REPPOyrAspdeOAV+6VKRavstea7+2DZmSUgE -----END RSA PRIVATE KEY----- rsa_public: ssh-rsa AAAAB3NzaC1yc2E...18QJvWPocKJtlsDNi3 smoser@host dsa_private: | -----BEGIN DSA PRIVATE KEY----- MIIBuwIBAAKBgQDP2HLu7pTExL89USyM0264RCyWX/CMLmukxX0Jdbm29ax8FBJT ... 8KucvUYbOEI+yv+5LW9u3z/BAoGBAI0q6JP+JvJmwZFaeCMMVxXUbqiSko/P1lsa -----END DSA PRIVATE KEY----- dsa_public: ssh-dss AAAAB3NzaC1kc3M...ybngIy66PMEoQ= smoser@host ----
Diffstat (limited to 'ec2init/CloudConfig.py')
-rw-r--r--ec2init/CloudConfig.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/ec2init/CloudConfig.py b/ec2init/CloudConfig.py
index 17a14363..d6947ce1 100644
--- a/ec2init/CloudConfig.py
+++ b/ec2init/CloudConfig.py
@@ -158,11 +158,18 @@ class CloudConfig():
try: os.unlink(f)
except: pass
- if False:
+ if self.cfg.has_key("ssh_keys"):
# if there are keys in cloud-config, use them
- # TODO: need to get keys from cloud-config if present
- # and replace those in /etc/ssh
- pass
+ key2file = {
+ "rsa_private" : ("/etc/ssh/ssh_host_rsa_key", 0600),
+ "rsa_public" : ("/etc/ssh/ssh_host_rsa_key.pub", 0644),
+ "dsa_private" : ("/etc/ssh/ssh_host_dsa_key", 0600),
+ "dsa_public" : ("/etc/ssh/ssh_host_dsa_key.pub", 0644)
+ }
+
+ for key,val in self.cfg["ssh_keys"].items():
+ if key2file.has_key(key):
+ util.write_file(key2file[key][0],val,key2file[key][1])
else:
# if not, generate them
genkeys ='ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""; '