Enable Passwordless Authenication Between Linux Machine
Let’s consider linux machine as Host 1 and Host 2, we will enable passwordless authenication from host 1 to host 2
Host 1:
- Create a new user for ansible administration & grant admin access to user
useradd ansadmin passwd ansadmin
- Add below lines to visudo
visudo ansadmin ALL=(ALL) NOPASSWD: ALL
- 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
- Restart sshd service
service sshd restart
Host 2:
- Create a new user for ansible administration & grant admin access to user
useradd ansadmin passwd ansadmin
- Add below lines to visudo
visudo ansadmin ALL=(ALL) NOPASSWD: ALL
- 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
- Restart sshd service
service sshd restart
Host 1:
- Login as a ansadmin user
su - ansadmin
- Generate SSH
ssh-keygen
- Copy keys onto Host 2
ssh-copy-id <Host 1 IP address>