move writing of ssh key fingerprints to a separate tool
This will allow this code to be called more easily elsewhere. I'm considering having the "all the way up" message contain fingerprints so that they're more or less guaranteed to get to the console where the user could see them.
This commit is contained in:
@@ -60,18 +60,7 @@ def handle(name,cfg,cloud,log,args):
|
||||
send_ssh_keys_to_console()
|
||||
|
||||
def send_ssh_keys_to_console():
|
||||
send_keys_sh = """
|
||||
{
|
||||
echo
|
||||
echo "#############################################################"
|
||||
echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----"
|
||||
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
|
||||
ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
|
||||
echo "-----END SSH HOST KEY FINGERPRINTS-----"
|
||||
echo "#############################################################"
|
||||
} | logger -p user.info -s -t "ec2"
|
||||
"""
|
||||
subprocess.call(('sh', '-c', send_keys_sh))
|
||||
subprocess.call(('/usr/lib/cloud-init/write-ssh-key-fingerprints',))
|
||||
|
||||
def apply_credentials(keys, user, disable_root):
|
||||
keys = set(keys)
|
||||
|
||||
3
setup.py
3
setup.py
@@ -41,7 +41,8 @@ setup(name='cloud-init',
|
||||
('/etc/cloud/templates', glob('templates/*')),
|
||||
('/etc/init', glob('upstart/*.conf')),
|
||||
('/usr/share/cloud-init', []),
|
||||
('/usr/lib/cloud-init', ['tools/uncloud-init']),
|
||||
('/usr/lib/cloud-init',
|
||||
['tools/uncloud-init', 'tools/write-ssh-key-fingerprints']),
|
||||
('/usr/share/doc/cloud-init', filter(is_f,glob('doc/*'))),
|
||||
('/usr/share/doc/cloud-init/examples', filter(is_f,glob('doc/examples/*'))),
|
||||
('/usr/share/doc/cloud-init/examples/seed', filter(is_f,glob('doc/examples/seed/*'))),
|
||||
|
||||
10
tools/write-ssh-key-fingerprints
Executable file
10
tools/write-ssh-key-fingerprints
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
{
|
||||
echo
|
||||
echo "#############################################################"
|
||||
echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----"
|
||||
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
|
||||
ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
|
||||
echo "-----END SSH HOST KEY FINGERPRINTS-----"
|
||||
echo "#############################################################"
|
||||
} | logger -p user.info -s -t "ec2"
|
||||
Reference in New Issue
Block a user