Member-only story

Access EC2 without pem file with with username and password — boobo94

Bogdan Alexandru Militaru
1 min readJul 30, 2020

Sometimes you need to grant permissions to someone else and maybe you don’t want to share the .pem file. By default, the ssh access is granted through a .pem file by Amazon EC2.

$ ssh -i pem_file.pem ubuntu@ec2-________.compute-1.amazonaws.com

2. Create a new user

$ sudo useradd -s /bin/bash -m -d /home/USERNAME -g root USERNAME

3. Add a password

$ sudo passwd USERNAME

4. Add users to sudoers

$ sudo visudo

Here you need to add the following line

USERNAME ALL=(ALL:ALL) ALL

5. Enable the access by password through ssh

$ vi /etc/ssh/sshd_config

Here you need to search PasswordAuthentication from no to yes.

6. Restart ssh

$ sudo /etc/init.d/ssh restart

7. Connect to the server using the new user

$ ssh USERNAME@ec2-________.compute-1.amazonaws.com

This is all.

If you consider this tutorial was useful please let me a comment or share the article. For any suggestions or comments, please drop me a line below.
I have an article that may be interested in you, on the same subject Don’t play stupid with the security of your app

Originally published at https://whyboobo.com/devops/access-ec2-with-username-and-password/ on July 30, 2020.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response