在远程服务器上创建密钥对.
ssh-keygen -t rsa
新建authorized_keys文件
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
修改authorized_keys权限为拥有者可读写
chmod 600 ~/.ssh/authorized_keys
禁止密码登录
vi /etc/ssh/sshd_config
找到
PasswordAuthentication
将其值改为no
重启ssh服务
systemctl restart sshd
或者service sshd restart