Login To EC2 Instance
$ ssh -i my.pem ec2-user@ec2-xxxxxxx.amazonaws.com
Create a new user
Become root on my EC2 instance:[ec2-user@ip-xxxxx ~]$ id
uid=222(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
[ec2-user@ip-xxxxx ~]$ sudo su -
[root@ip-xxxxx ~]#
[root@ip-xxxxx ~]# useradd elousf
[root@ip-xxxxx ~]# passwd elousf
Changing password for user elousf.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@ip-xxxxx ~]# cp -r ~ec2-user/.ssh ~elousf/
[root@ip-xxxxx ~]# cd ~elousf/
[root@ip-xxxxx elousf]# ls -ltr .ssh
total 4
-rw------- 1 root root 389 Jul 2 03:28 authorized_keys
[root@ip-xxxxx elousf]# chown -R elousf:elousf .ssh
[root@ip-xxxxx elousf]# chmod 700 .ssh
[root@ip-xxxxx elousf]# chmod 600 .ssh/authorized_keys
[root@ip-xxxxx elousf]# ls -ltr .ssh
total 4
-rw------- 1 elousf elousf 389 Jul 2 03:28 authorized_keys
[root@ip-xxxxx elousf]# exit
logout
[ec2-user@ip-xxxxx ~]$ exit
logout
Connection to ec2-54-215-48-188.us-west-1.compute.amazonaws.com closed.
Now, I'm back to my macbook pro and login in to EC2 as elousf user:
@mbp ~$ ssh -i my.pem elousf@ec2-54-215-48-188.us-west-1.compute.amazonaws.com
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2013.03-release-notes/
From now on I can use my user elousf to login to EC2.
No comments:
Post a Comment