Linux

How To Set Password on Linux in AWS EC2 Instances?

When you install a Linux operating system on Amazon EC2 instances, by default password authentication is disabled, you need to enable it first to login by using a password.

Please read How to install Rocky Linux on Amazon ec2 if you want to know about it. To login you need a “.pem” file when you first time install the Linux OS as shown below in the terminal or command.

ssh -i "path-to-downloaded-keypair" rocky@server-public-ip-address

Set Password on Linux OS in EC2 Instance

Step 1: First login into the Linux OS using a key file as shown in the image below.

Step 2: Now login as root and use the following command to open the sshd config file.

$ sudo su
$ vi /etc/ssh/sshd_config

Step 3: Search for “PasswordAuthentication”. Enable search option by typing forward slash “/” and uncomment “PasswordAuthentication yes” and comment “PasswordAuthentication no”.

Step 4: Save and exit the file by typing Esc, Shift + :, wq and hit Enter button.

Step 5: Restart sshd service.

$ systemctl restart sshd.service

Step 6: Now set the password for user “centos” by using the following command and enter the new password two times. Exit the terminal and use the public IP in SSH. And finally, use a username and password to login.

$ passwd centos
You Might Also Like

More Similar Posts

Tags

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Menu
0
Would love your thoughts, please comment.x
()
x