- RSA私钥及公钥生成
- ssh-keygen -b 2048 -t rsa
-
Enter file in which to save the key:
-
Enter passphrase (empty for no passphrase):
-
Enter same passphrase again:
- 上传公钥到服务器端
- scp {local_id_rsa.pub_path} {remote_host_ip}:{destination_path}
- 服务器端配置
- cat {destination_path} >> ~/.ssh/authorized_keys
-
chmod 700 ~/.ssh
- chmod 700 ~/.ssh/authorized_keys
-
vim /etc/ssh/sshd_config
删除RSAAuthentication和PubkeyAuthentication前的'#'号RSAAuthentication yes
PubkeyAuthentication yes
- 重启ssh
/etc/init.d/sshd restart