$ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/username/.ssh/id_rsa. Your public key has been saved in /home/username/.ssh/id_rsa.pub.
$ ssh-copy-id id@server //用户名@服务器地址 id@server's password:
$ ssh-copy-id root@服务器地址 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/31325/.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@服务器地址's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@服务器地址'" and check to make sure that only the key(s) you wanted were added.