First, generate the public key on the local machine: Java code [root@localhost.ssh] # ssh-keygen-d always press the Enter key Generatingpublic/privatedsakeypair. enterfileinwhichtosavethekey (/root /. ssh/id_dsa ):...
First, generate a public key on the local machine:
Java code
[Root @ localhost. ssh] # keep pressing the enter key for ssh-keygen-d
Generating public/private dsa key pair.
Enter file in which to save the key (/root/. ssh/id_dsa ):
/Root/. ssh/id_dsa already exists.
Overwrite (y/n )? Y
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
Your identification has been saved in/root/. ssh/id_dsa.
Your public key has been saved in/root/. ssh/id_dsa.pub.
The key fingerprint is:
89: 77: aa: a2: d8: 31: 35: 1e: 3a: 34: 9e: b9: da: ea: 62: 34 root@localhost.localdomain
[Root @ localhost. ssh] #
Then, upload the generated public key to the remote machine that you want to log on to. if the root user logs on remotely, put the public key under the/root/. sshd directory.
Java code
[Root @ localhost. ssh] # scp/root/. ssh/id_dsa.pub root@192.168.0.60:/root/. ssh/
Root@192.168.0.60's password: Enter the login password for the remote machine
Id_dsa.pub 100% 616 0.6KB/s
And modify the file name:
Java code
[Root @ web1. ssh] # mv id_dsa.pub authorized_keys
Finally, ssh password-free login is implemented.
SSH password-free login:
Java code
[Root @ localhost. ssh] # ssh root@192.168.0.60
Last login: Tue Sep 27 09:03:10 2011 from 192.168.0.3
[Root @ web1 ~] #
Author: "birds of heaven"