From 40bc760f17a67700ad19b0d2250deec4e5e06954 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Wed, 4 Feb 2009 17:54:00 +0000 Subject: * debian/init: - Remove already ran detection - Log the running of ec2-run-user-data to /var/log/ec2-user-data.log * ec2-set-hostname.py: - set hostname to the Ec2 local-hostname - Update the /etc/hosts to change the ubuntu hostname to the public hostname. * ec2-fetch-credentials: - Copy the ssh keys to the ubuntu user. - Setup authorized keys for root to tell the user to login as the ubuntu user when they try to connect. * ec2-run-user-data: - Create an .already-ran file to check to see if ec2-run-user-data already ran. - Save the ec2-run-user-data script in /var/ec2. --- ec2-fetch-credentials.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'ec2-fetch-credentials.py') diff --git a/ec2-fetch-credentials.py b/ec2-fetch-credentials.py index 80980924..1e91bef8 100755 --- a/ec2-fetch-credentials.py +++ b/ec2-fetch-credentials.py @@ -34,10 +34,16 @@ keys = get_ssh_keys() os.umask(077) -if not os.path.exists('/root/.ssh'): - os.mkdir('/root/.ssh') +if not os.path.exists('/home/ubuntu/.ssh'): + os.mkdir('/home/ubuntu/.ssh') -fp = open('/root/.ssh/authorized_keys', 'a') +fp = open('/home/ubuntu/.ssh/authorized_keys', 'a') fp.write(''.join(['%s\n' % key for key in keys])) fp.close() +os.system('chown -R ubuntu:ubuntu /home/ubuntu/.ssh') + +fp = open('/root/.ssh/authorized_keys', 'a') +fp.write("command=\"echo;echo \'Please use the \"ubuntu\" user to login on this host instead of \"root\".\'echo;sleep 10\"") +fp.write('',join(['%s\n' % key for key in keys])) +fp.close() -- cgit v1.2.3