Dear Readers,
In this article, we will see the following Configure SSH Password Authentication For Amazon EC2 Instance .
Steps to Follow :
- Logging to AWS Account
- Launch Linux Server
- Connect to Linux EC2 Instance by Using Putty
- Enable SSH Password Authentication
- Connect to Linux EC2 Instance with username and password (without keypair)
1. Logging to AWS Account
First, we need to AWS Console page by using below link.
https://aws.amazon.com/console/
Click on sign in to Console button.
Logging to aws account
Login using username & password and click on sign in.
Enter to AWS Management Console
We can see the AWS Management Console Dashboard.
Go to Services, under the compute module click EC2 service to open.
2. Launch Linux EC2 Instance
Go to Services, under the compute module click EC2 service to open.
We can launch Linux EC2 Instance by using below link.
How to Launch Linux EC2 Instance
We can see the Linux server has been launched successfully.
3. Connect to Linux EC2 Instance Using Putty
We can connect putty by using below link.
Connect to EC2 Instance Using Putty
4. Enable SSH Password Authentication
Go inside the Linux Server Terminal.
1 2 3 4 5 6 7 8 9 10 11 |
login as: ec2-user Authenticating with public key "imported-openssh-key" __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ 2 package(s) needed for security, out of 13 available Run "sudo yum update" to apply all updates. [ec2-user@ip-172-31-6-132 ~]$ |
Create Password for root
1 2 3 4 5 6 7 |
[ec2-user@ip-172-31-6-132 ~]$ sudo su [root@ip-172-31-6-132 ec2-user]# passwd root Changing password for user root. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. |
Open sshd_config file and change parameter like comment PasswordAuthentication no ,uncomment PasswordAuthentication and comment PermitRootLogin yes.
1 2 3 4 |
[root@ip-172-31-6-132 ~]# vi /etc/ssh/sshd_config PermitRootLogin yes PasswordAuthentication yes #PasswordAuthentication no |
Note: Keep in ESC mode then type wq! press enter to save and quit.
Restart sshd configuration file
1 2 |
[root@ip-172-31-6-132 ec2-user]# service sshd restart Redirecting to /bin/systemctl restart sshd.service |
5. Connect to Linux EC2 Instance with username and password (without keypair)
Go to your instance and copy Public IPV4 address.
Go to seachbar and open putty by typing putty on search bar.
Open putty and specify Public IPV4 which was copied.
Specify username “root” and password which was created.
We can see the terminal of Linux server.
We have connected to Linux server by using username and password without having key pair.
1 2 3 4 5 6 7 8 9 10 11 12 |
login as: root root@13.233.154.38's password: Last login: Sun Oct 11 12:05:05 2020 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ 2 package(s) needed for security, out of 13 available Run "sudo yum update" to apply all updates. [root@ip-172-31-6-132 ~]# |
As of now we have seen enable password authentication if you want to disable the password authentication we can do following things.
Disable SSH Password Authentication
Go inside the Linux Server Terminal.
1 2 3 4 5 6 7 8 9 10 11 12 |
login as: root root@13.233.154.38's password: Last login: Sun Oct 11 12:05:05 2020 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ 2 package(s) needed for security, out of 13 available Run "sudo yum update" to apply all updates. [root@ip-172-31-6-132 ~]# |
Open sshd_config file and change parameter like uncomment PasswordAuthentication no ,comment PasswordAuthentication yes and uncomment PermitRootLogin yes.
1 2 3 |
#PermitRootLogin yes #PasswordAuthentication yes PasswordAuthentication no |
Note: Keep in ESC mode then type wq! press enter to save and quit.
Restart sshd configuration file
1 2 |
[root@ip-172-31-6-132 ec2-user]# service sshd restart Redirecting to /bin/systemctl restart sshd.service |
Now, we need connect to Linux EC2 Instance by using keypair. Because we have disabled password authentication.
Thank you for giving your valuable time to read the above information.
Follow us on
Website : www.ktexperts.com
Facebook Page : KTexperts
Linkedin Page : KT EXPERTS
Follow Me
Ramesh’s Linkedin : Ramesh Atchala