今天再次使用就做个记录了

[root@www ~]# ssh-keygen (创建命令)

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:

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:

d9:7e:3f:fc:52:03:bd:66:89:ed:c1:1b:c2:68:f5:64 root@www.bb.com

[root@www ~]# cd .ssh/ 进到这个目录

[root@www .ssh]# ls (可以看到如下两个文件  id_rsa为私钥 id_rsa.pub为公钥)

id_rsa  id_rsa.pub

[root@www .ssh]# scp id_rsa.pub root@192.168.1.120:/root/.ssh/authorized_keys (把公钥拷到你需要登录的服务器上 并重名为authorized_keys

[root@www .ssh]# ssh 192.168.1.120 (然后ssh 就可以实现不需要密码的登录了)