一.生成密钥的公钥和私钥
1.ssh-keygen -t rsa
二.将生成的私钥(id_rsa)下载到本地的windows机,并把公钥导入到.ssh/authorized_keys 文件中去
1.#cd /root/.ssh/
2.#cat id_rsa.pub > authorized_keys
三.sshd配置
1.sshd配置文件路径 /etc/ssh/sshd_config
2.
四.设置sshd 服务器服务,打开以下设置:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile /root/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
五.重启ssh服务
1. #service ssh restart (注意:如果是centos7以下版本)
2.如果是centos7以上
查看ssh服务状态:systemctl status sshd.service
开启ssh服务:systemctl start sshd.service
重启ssh服务:systemctl restart sshd.service
服务器自动开启:systemctl enable sshd.service
六.xshell登录
添加id_rsa私钥文件,输入建立私钥时候的密码,就成功了。
本文出自 “Note” 博客,转载请与作者联系!
原文地址:http://3miao.blog.51cto.com/9661385/1979108