1.生成私钥与公钥并将公钥上传到应用服务器
2.切换到密钥生成目录,将公钥写入 id_rsa.pub 换成生成和上传的文件名
cd .ssh
cat id_rsa.pub >> authorized_keys
3.设置权限
chmod 600 authorized_keys
chmod 700 ~/.ssh
4.修改配置文件sshd_config
vi /etc/ssh/sshd_config 添加、修改
RSAAuthentication yes
PubkeyAuthentication yes
!!!!!!坑
把PasswordAuthentication的属性改为no
PermitRootLogin no ##禁止root登录
PasswordAuthentication no ##不能用密码登录方式,只能用密钥方式
5.systemctl restart sshd 重启ssh服务