Skip to content

How to Enable Password Authentication in AWS ec2 Instances

Although password will be encrypted while communicating with server but it is not recommended to enable the password authentication to connect with EC2 machines using ssh. Easy and common password can be guessed easily using brute force by some malicious user.

  1. Log in to the server using ssh client of your choice using the private key.

    ssh -i your-key.pem username@ip_address
    

  2. Set up a password for the user using passwd command along with the username.

    sudo passwd ec2-user # If machine is Amazon Linux
    sudo passwd ubuntu # If machine is Ubuntu
    

  3. Open the sshd_config file.

    sudo vi /etc/ssh/sshd_config
    

  4. Find the Line containing "PasswordAuthentication" parameter and change its value from "no" to "yes". If you want to set up "root" login, find "PermitRootLogin" parameter and change its value from prohibit-password to "yes".

  5. Now, restart the "sshd" service using the following command.

    sudo service sshd restart
    

  6. Now you can log out and log in using the password you set for the user.

    ssh ec2-user@ip_address
    

Comments