Temporarily enable SSH password authentication on RHEL/Centos VMs.

To enable password based authentication on RHEL/Centos machines, login as root to the target host. ( sudo the commands below if you are not logging in as root)

1. Create the password authenticated user if not already created –

  • On console run : adduser [username]
  • Set a password for the new user: passwd [username]

2. Add the user to sudoers and enable remote login –

  • On console run: visudo
  • In the file opened for editing, comment out the line – “Defaults    requiretty
  • Add the line “[username] ALL=(ALL)       ALL”  below the line “root ALL=(ALL)       ALL

3. Enable password authentication for SSH.

  • vi /etc/ssh/sshd_config
  • Replace the line “PasswordAuthentication no” with “PasswordAuthentication yes“. (Uncomment this line if commented.) Save and close this file.
  • /etc/init.d/sshd reload

4. To disable password authentication after use, in the above file replace “PasswordAuthentication yes” with “PasswordAuthentication no“; reload sshd as before.

Kj
Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.

Leave a Comment

Your email address will not be published. Required fields are marked *