- 在本地
~/.ssh
文件夾生成公私鑰對:
id_rsa; id_rsa.pub. 將id_rsa.pub內(nèi)容復(fù)制到服務(wù)器 ~/.ssh/authorized_keys文件
- 本地~/.ssh中創(chuàng)建config
Host cloud
HostName 8.129.49.94
User zhiyuan
Port 22
#IdentityFile ~/.ssh/id_rsa # 都可以
PubkeyAuthentication yes
Host local
HostName 192.168.107.128
User zhiyuan
Port 22
IdentityFile ~/.ssh/id_rsa
當(dāng)配置完后仍需要密碼時:
# 1. 服務(wù)端查看系統(tǒng)日志文件
trail /var/log/secure (-n 20可選)
# Authentication refused: bad ownership or modes for file
# 2. 修改目錄, 文件權(quán)限
chmod g-w /home/zhiyuan
chmod 700 /home/zhiyuan/.ssh
chmod 600 /home/zhiyuan/.ssh/authorized_keys