- Login as a
ec2-user
to the instance
$ ssh -i ~/.ssh/<key> ec2-user@<ip-address>
- Create user
$ sudo useradd newuser
- Allow ssh access for the user
Login as new user
$ sudo -su newuser
Create ssh directory
$ cd /home/newuser
$ mkdir .ssh
$ chmod 700 .ssh
$ cd .ssh
Add ssh key
$ touch authorized_keys
$ chmod 600 authorized_keys
$ echo "<public_key>" > authorized_keys
- Validate access
$ ssh -i ~/.ssh/newuser-private-key newuser@<ip-address>