- 服務(wù)端用戶目錄下生產(chǎn)密鑰對(duì)
#ssh-keygen –t rsa
- 將公鑰id_rsa.pub內(nèi)容添加到用戶目錄下.ssh文件夾的authorized_keys文件中(有則添加無則創(chuàng)建)锈候,并修改權(quán)限為600。
id_rsa 私鑰,用戶使用
id_rsa.pub 公鑰,服務(wù)器使用
# 修改authorized_keys權(quán)限
#chmod 600 authorized_keys
- 配置sshd_config
# vim /etc/ssh/sshd_config
#Port 22 //取消注釋,修改端口為其他(iptables和防火墻要開啟該端口) //Port 8822
PasswordAuthentication yes //將該項(xiàng)改為no
PubkeyAuthentication no //將該項(xiàng)改為yes
UsePAM yes //將該項(xiàng)改為no
- 重啟sshd服務(wù)
#systemctl restart sshd.service