$ ssh-keygen Generating public/private rsa key pair. Enter file inwhich to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 38:3c:57:d5:fa:9f:77:06:2d:1a:2f:d5:b7:55:ac:fd root@iZ28cqmea34Z The key's randomart image is: +--[ RSA 2048]----+ | .. | | . . | | . . . | | . . . . o| | = S . =.| | + . * *| | = +*| | o .oE| | . .o| +-----------------+
复制公钥到目标主机
1 2 3 4 5 6 7
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.2.200 root@192.168.2.200's password: //输入密码 Now try logging into the machine, with "ssh '用户名@远程主机'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.