主机A(OpenSUSE12.1):119.78.222.95

主机B (Fedora16): 202.122.25.36


1.主机A:生成秘钥对id_rsa和id_rsa.pub


linux-9juc:~ # ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again: Enter

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:Enter

52:65:a0:7a:9a:42:55:a7:83:eb:d1:a0:f6:2a:e3:cf root@linux-9juc

The key's randomart p_w_picpath is:Enter

+--[ RSA 2048]----+

| . o.o |

| o + o |

| + + . |

| o = o |

| + + + S |

| o o = . |

| . = |

|o .o |

|.+oE |

+-----------------+


2.将主机A上生成的秘钥拷贝到主机B

linux-9juc:~/.ssh # ssh-copy-id -i id_rsa.pub [email protected]



3.重新登陆

linux-9juc:~/.ssh # ssh root@202.122.25.36

Last login: Mon Sep 16 13:18:57 2013 from 202.122.25.36

成功