2)其它用户创建 [root@controller1 ~]# adduser sds [root@controller1 ~]# su - sds [sds@controller1 ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/sds/.ssh/id_rsa): Created directory '/home/sds/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/sds/.ssh/id_rsa. Your public key has been saved in /home/sds/.ssh/id_rsa.pub.
密钥对存放在用户的家目录中:/home/sds/.ssh/id_rsa.pub
(2)将客户机中的公钥复制到目标机B中 1)用ssh-copy-id工具分发公钥 [root@controller1 .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub 172.16.100.73 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '172.16.100.73 (172.16.100.73)' can't be established. ... /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@172.16.100.73's password: Number of key(s) added: 1
Now try logging into the machine, with: "ssh '172.16.100.73'" and check to make sure that only the key(s) you wanted were added.