2行命令
ssh-keygen #生成本地秘钥 ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip地址
输入密码,即可将公钥追加到新的服务器中
\[root@MiWiFi-RA69-srv ~\]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@47.106.110.119 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /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@47.106.110.119's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@47.106.110.119'" and check to make sure that only the key(s) you wanted were added.