# visudo
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
ansadmin ALL=(ALL) NOPASSWD: ALL --> added
Enable password based login
# vi /etc/ssh/sshd_config
PasswordAuthentication no -> yes
# systemctl reload sshd.service
Generate ssh keys
# sudo su ansadmin
ssh login with password -> ansadmin -> fail!
# ssh-keygen
/home/ansadmin/.ssh/id_rsa -> ssh key location
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ansadmin/.ssh/id_rsa):
Created directory '/home/ansadmin/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ansadmin/.ssh/id_rsa.
Your public key has been saved in /home/ansadmin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:T/1aPkUMmLuPa5TngVE0NnfHtyFCw+rsRy1PbUEIXRA ansadmin@ansible-server
The key's randomart image is:
+---[RSA 2048]----+
| o+oEXo+|
| o+=o*=|
| . .ooo+|
| . .o oo|
| S . o=...|
| = o=+oo.|
| . o.+=+o |
| . .o=+ |
| ..o... |
+----[SHA256]-----+
[ansadmin@ansible-server ~]$ ssh-copy-id 172.31.38.162 -> docker-server
yes
1234
[ansadmin@ansible-server docker]$ sudo vim /etc/ansible/hosts
[dockerserver]
172.xxx.xxx.xxx -> docker server private ip
[ansible]
172.xxx.xxx.xxx -> ansible server private ip
[ansadmin@ansible-server docker]$ ansible all -a uptime
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
172.xxx.xxx.xxx | UNREACHABLE! => { --> solve this
[ansadmin@ansible-server docker]$ ssh-copy-id 172.xxx.xxx.xxx -> ansible-server
[email protected]'s password: 1234
[ansadmin@ansible-server docker]$ ansible all -a uptime