How to Enable Password-Based Authentication in AWS EC2 Servers


AWS EC2 servers do not allow users to log in with passwords by default. To log in to the EC2 server, a key pair is required. While it is safer to allow only key pair-based authentication, sometimes you may be required to log in with a username and password.

If you attempt to log in without selecting a key pair an error message will be thrown at you:  No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)

In this article, we will see how to enable password based authentication for AWS EC2 Server.

Enable Password Authentication In AWS EC2 Server

Log in to the AWS EC2 server with your key pair and update sshd_config file.

$ sudo vi /etc/ssh/sshd_config

Add the following line to the file:

PasswordAuthentication yes

Restart the sshd service:

 $ sudo service sshd restart

This will allow users to log in by giving in a username and a password.

Now to log in as root, change the password of the root user and specify a new password:

$ sudo passwd root

You are good to go. Log out and log in with root user.



I am a dreamer. I admire the web. I admire anything about the web.