client1: 192.168.4.11 Linux Host
server1: 192.168.4.33 Linux Host
client server Generate key(Public key and Private key), copy the Public key to server1
1.client1 Generate key
[root@client1 ~]# ssh-keygen -b 1024 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): #Key storage Path
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:
-b 1024 length of the key(Public key and Private key) is 1024 Byte, max length is 4096 Byte.
-t rsa the key(Public key and Private key) is by rsa Encryption, In addition there ssh dsa way, rsa way length not less than 768 Bytes
2.copy the public key to server1
[root@server1 ~]# scp /root/.ssh/id_rsa.pub email@example.com:/root
The authenticity of host '192.168.4.33 (192.168.4.33)' can't be established.
RSA key fingerprint is 91:a9:f9:6c:cd:6b:69:69:78:e0:f0:0f:a1:7f:c3:d8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.4.33' (RSA) to the list of known hosts.
id_rsa.pub 100% 226 0.2KB/s 00:00
3.server1 set authorized_keys
[root@server1 ~]# mkdir .ssh
[root@server1 ~]# cat id_rsa.pub >> .ssh/authorized_keys
[root@server1 ~]# chmod -R 600 .ssh
[root@server1 ~]# ll .ssh/authorized_keys
-rw------- 1 root root 226 07-19 23:54 .ssh/authorized_keys
4.client1 login to server1
[root@server3 ~]# ssh -lroot 192.168.4.33
Enter passphrase for key '/root/.ssh/id_rsa': (If you set up, you need to fill in)
Last login: Fri Jul 20 00:39:36 2012 from 192.168.4.11