- Create a key pair for the new user account
- Connect with root into SSH
- Run following commands
- $ sudo adduser deployer OR sudo adduser new_user --disabled-password (without password)
- $ sudo su - new_user
- $ mkdir .ssh
- $ chmod 700 .ssh
- $ touch .ssh/authorized_keys
- $ chmod 600 .ssh/authorized_keys
- [IN LOCAL SYSTEM] Retriev the Public Key for the Key Pair we just created in STEP-1, command below
-
$ ssh-keygen -y -f /path_to_key_pair/my-key-pair.pem
-
If the command fails, ensure that you've changed the permissions on your key pair file so that only you can view it by running the following command: $ chmod 400 my-key-pair.pem
-
and then do ssh-keygen command again
- cat >> .ssh/authorized_keys
- Paste the public key into the .ssh/authorized_keys file and then press Enter
- Ctrl + d to finish
Finally, Verify that you can connect to your EC2 instance using ssh as the new_user by running the following command from a command line prompt on your local computer $ ssh -i /path/new_key_pair.pem new_user@public_dns_name_of_EC2_Linux_instance