在遠(yuǎn)程服務(wù)器上創(chuàng)建密鑰對.
ssh-keygen -t rsa
新建authorized_keys文件
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
修改authorized_keys權(quán)限為擁有者可讀寫
chmod 600 ~/.ssh/authorized_keys
禁止密碼登錄
vi /etc/ssh/sshd_config
找到
PasswordAuthentication
將其值改為no
重啟ssh服務(wù)
systemctl restart sshd
或者service sshd restart