Enable Passwordless Authenication Between Linux Machine

0 102

Let’s consider linux machine as Host 1 and Host 2, we will enable passwordless authenication from host 1 to host 2

Host 1:

  1. Create a new user for ansible administration & grant admin access to user
    useradd ansadmin
    
    passwd ansadmin
  2. Add below lines to visudo
    visudo
    
    ansadmin ALL=(ALL) NOPASSWD: ALL

  3. Using key-based authentication is advised. If you are still at learning stage use password based authentication:
    sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
  4. Restart sshd service
    service sshd restart

Host 2:

  1. Create a new user for ansible administration & grant admin access to user
    useradd ansadmin
    
    passwd ansadmin
  2. Add below lines to visudo
    visudo
    
    ansadmin ALL=(ALL) NOPASSWD: ALL

  3. Using key-based authentication is advised. If you are still at learning stage use password based authentication:
    sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
  4. Restart sshd service
    service sshd restart

Host 1:

  1. Login as a ansadmin user
    su - ansadmin
  2. Generate SSH
    ssh-keygen
  3. Copy keys onto Host 2
    ssh-copy-id <Host 1 IP address>

Leave A Reply

Your email address will not be published.