~ubuntu-branches/ubuntu/oneiric/cloud-init/oneiric-updates

« back to all changes in this revision

Viewing changes to cloudinit/CloudConfig/cc_ssh.py

  • Committer: Package Import Robot
  • Author(s): Scott Moser
  • Date: 2011-08-23 00:01:01 UTC
  • Revision ID: package-import@ubuntu.com-20110823000101-gnmcdm4wk88sd6vn
Tags: 0.6.1-0ubuntu15
* catch up with trunk at revision 431
* add network debug info to console when cloud-init runs (LP: #828186)
* fix issue where subprocesses (apt-add-repository) where given
  the console and would attempt to prompt user and hang boot (LP: #831505)
* add awareness of ecdsa to cc_ssh

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
            "rsa_private" : ("/etc/ssh/ssh_host_rsa_key", 0600),
41
41
            "rsa_public"  : ("/etc/ssh/ssh_host_rsa_key.pub", 0644),
42
42
            "dsa_private" : ("/etc/ssh/ssh_host_dsa_key", 0600),
43
 
            "dsa_public"  : ("/etc/ssh/ssh_host_dsa_key.pub", 0644)
 
43
            "dsa_public"  : ("/etc/ssh/ssh_host_dsa_key.pub", 0644),
 
44
            "ecdsa_private" : ("/etc/ssh/ssh_host_ecdsa_key", 0600),
 
45
            "ecdsa_public"  : ("/etc/ssh/ssh_host_ecdsa_key.pub", 0644),
44
46
        }
45
47
 
46
48
        for key,val in cfg["ssh_keys"].items():
47
49
            if key2file.has_key(key):
48
50
                util.write_file(key2file[key][0],val,key2file[key][1])
49
51
 
50
 
        priv2pub = { 'rsa_private':'rsa_public', 'dsa_private':'dsa_public' }
 
52
        priv2pub = { 'rsa_private':'rsa_public', 'dsa_private':'dsa_public',
 
53
            'ecdsa_private': 'ecdsa_public', }
 
54
 
51
55
        cmd = 'o=$(ssh-keygen -yf "%s") && echo "$o" root@localhost > "%s"'
52
56
        for priv,pub in priv2pub.iteritems():
53
57
            if pub in cfg['ssh_keys'] or not priv in cfg['ssh_keys']: continue
58
62
        # if not, generate them
59
63
        genkeys ='ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""; '
60
64
        genkeys+='ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ""; '
 
65
        genkeys+='ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ""; '
61
66
        subprocess.call(('sh', '-c', "{ %s } </dev/null" % (genkeys)))
62
67
 
63
68
    try: