Para que seja possível uma conexão SSH sem senha entre host1 e host2, é preciso entregar para o servidor a chave pública gerada pelo host1.[divider]
Passo 1
No computador host1 execute o seguinte comando:
# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key
(/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in
/root/.ssh/id_rsa.
Your public key has been saved in
/root/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
The key’s randomart image is:
+–[ RSA 2048]—-+
| |
| . |
| . a . |
| = o |
| . A . . Z |
| . . o . * |
| o + o + + |
| . + d * . |
| =.+.+|
+—————–+
Quando questionado para entrar com uma “passphrase”, apenas tecle “Enter”, duas vezes, para evitar que digitemos a ‘passphrase’ uma segunda vez.[divider]
Passo 2
No host 1:
# scp /root/.ssh/id_rsa.pub root@host2:/root/
(digitar senha)
# ssh root@host2
(digitar senha)
# cat /root/id_rsa.pub >> /root/.ssh/authorized_keys
[divider]
Agora as conexões SSH iniciadas pelo host1 para o host2 serão efetuadas sem a necessidade de digitar a senha.