diff options
Diffstat (limited to 'ec2-fetch-credentials.py')
-rwxr-xr-x | ec2-fetch-credentials.py | 12 |
1 files changed, 9 insertions, 3 deletions
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() |