Login SSH senza password



Obiettivo

Tu vuoi usare Linux e OpenSSH per automatizzare i tuoi task. Per cui hai bisogno
di un login automatico e sicuro dall' host A / utente b all'Host B / utente b.
Non vuoi inserire password, per poter eseguire i ssh all'intereno di uno shell script.

Come fare

Prima log in su A come utente  a,  e genera una coppia di chiavi di autenticazione.
Non inserire passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Ora usa ssh per creare una directory ~/.ssh come utente b su B. (La directory potrebbe gia' esistere, il che va bene...):

a@A:~> ssh b@localhost mkdir -p .ssh
b@localhost's password:

Ora appendi la nuova chive pubblica di a su b@B:.ssh/authorized_keys ed inserisci la password di b per l'ultima volta:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:

Da ora in poi, potrai loggarti da A a B come b senza inserire password:

a@A:~> ssh b@B hostname
B
ยป

Comments

Invia nuovo commento

  • Linee e paragrafi vanno a capo automaticamente.
  • Web page addresses and e-mail addresses turn into links automatically.

Maggiori informazioni sulle opzioni di formattazione.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.