HasOne
Posted on April 21, 2021
you may find a situation where you want to access your Linux instance from someone's else machine, but your Linux need the .pem
key file and you don't want to carry your .pem
file to other's machine. why not just create a password for ssh, so let's create it
1) first you have to log in to your Linux box using .pem
$ ssh -i your_pem_file.pem ubuntu@ec2-________.compute-1.amazonaws.com
2) create a user that will access the instance using a password
$ sudo useradd -s /bin/bash -m -d /home/USERNAME -g root USERNAME
3) create a strong password for the new created user
$ sudo passwd USERNAME
Enter new UNIX password:
Retype new UNIX password:
4) Add user to the sudoers file by using sudo visudo
command
USERNAME ALL=(ALL:ALL) ALL
5) Enable password authenticating by editing /etc/ssh/sshd_config
file. and look for PasswordAuthentication
PasswordAuthentication no
# change it to yes
PasswordAuthentication yes
6) restart ssh demaon
$ sudo systemctl restart ssh
You're done, let's login by password
$ ssh USERNAME@hostname
BOOM you dit it. Make sure to create a strong password as it's less secure using a password rather than .pem
file.
Thank you so much for reading my article, I hope you got something to learn today. stay positive and happy coding.
anybody can succeed on the space, so don't listen to nay-sayer.
Posted on April 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.