$ cd ~/.ssh/
$ vi config
config内容如下,一个Host就是一个主机
Host test1
HostName 121.43.170.99
Port 22
User root
Host demo
HostName 12.34.56.78
Port 22
User root
$ ssh-keygen -t rsa
$ ls -al
可以看到,在.ssh目录下多了两个文件id_rsa和id_rsa.pub,私钥和公钥
$ cat id_rsa.pub
$ cd ~/.ssh
$ vi authorized_keys
cd /root/.ssh
touch authorized_keys
cat /root/.ssh/id_rsa.pub >> authorized_keys
sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
service sshd restart
$ ssh test1