root@ubuntu:~# ssh email@example.com The authenticity of host '192.168.1.88 (192.168.1.88)' can't be established. ECDSA key fingerprint is SHA256:/ufx+/OLtdsYy7vsdk4KDu9xJsBp6zHonRAf2jjT0GI. Are you sure you want to continue connecting (yes/no)? y Please type 'yes' or 'no': yes Warning: Permanently added '192.168.1.88' (ECDSA) to the list of known hosts. Password: Last login: Fri Dec 2 14:15:36 2016 localhost:~ root$
root@ubuntu:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/root/.ssh/id_rsa): Created directory '/home/root/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/root/.ssh/id_rsa. Your public key has been saved in /home/root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:8IVM56bc/2deLZcDXwVs2XDNCuTTbvvlCKmCnUxiHuw root@ubuntu The key's randomart image is: +---[RSA 2048]----+ | . ....o=o| | o + ...+o+| | . o + oo...| | + = o. .| | . S . .o .| | = . . oo.+| | + B . + o+=| | E = . o **| | .. o++| +----[SHA256]-----+
#生成的公钥私钥存放在.ssh目录下，id_rsa.pub就是本机的公钥 root@ubuntu:~$ cd .ssh/ root@ubuntu:~/.ssh$ ls id_rsa id_rsa.pub
root@ubuntu:~/.ssh$ ssh-copy-id "firstname.lastname@example.org" /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/root/.ssh/id_rsa.pub" The authenticity of host '192.168.1.88 (192.168.1.88)' can't be established. ECDSA key fingerprint is SHA256:/ufx+/OLtdsYy7vsdk4KDu9xJsBp6zHonRAf2jjT0GI. Are you sure you want to continue connecting (yes/no)? n^H Please type 'yes' or 'no': yes /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 Password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'email@example.com'" and check to make sure that only the key(s) you wanted were added.