1. Login to your EC2 instance using your
.pem file
ssh -i your_pem_file.pem ubuntu@ec2-________.compute-1.amazonaws.com
2. Create a new user that will access the instance using a password:
$ sudo useradd -s /bin/bash -m -d /home/USERNAME -g root USERNAME
where:
-s /bin/bash: use/bin/bashas the standard shell-m -d /home/USERNAME: create a home directory at/home/USERNAME-g root: add to grouprootUSERNAME: the username of the new user
$ sudo passwd USERNAME
Enter new UNIX password:
Retype new UNIX password:
4. Add user to sudoers file by using sudo visudo and add the following line:
USERNAME ALL=(ALL:ALL) ALL
5. Enable password authentication by editing /etc/ssh/sshd_config: change PasswordAuthentication noto PasswordAuthentication yes
6. Restart ssh:
sudo /etc/init.d/ssh restart
Logout of your instance (exit) and try your new login without the .pem file:
$ ssh USERNAME@ec2-________.compute-1.amazonaws.com
USERNAME@ec2-________.compute-1.amazonaws.com's password:
Enjoyed this article?
Show your appreciation with a clap
0claps
SK
You might also like
View all
Cloud & Infrastructure
Automate Virtual Machine Creation in Proxmox with Cloud-Init: Complete Guide
SKSohaib Khan

Cloud & Infrastructure
How to Install Bitninja for Cloudpanel Control for Server Security
SKSohaib Khan
U
Cloud & Infrastructure
Unleashing the Power of Hetzner Cloud with Bash and API Magic
SKSohaib Khan
Comments (0)
No comments yet. Be the first to comment!