服务器ssh_key授权,并禁止密码登陆
2017-03-13 11:52
281 查看
·生成rsa_key , 并添加公钥到服务器
windows:
下载XSHELL,在登陆的时候可以选择用密钥登陆, 然后直接生成,保存可以得到rsa_key.pub。linux or Mac:
1、生成SSH密钥对
ssh-keygen -t rsa
2、建议直接回车使用默认路径
Enter file in which to save the key (/root/.ssh/id_rsa):
3、输入密码短语(留空则直接回车)
Enter passphrase (empty forno passphrase):
4、重复密码短语
Enter same passphrase again:
最后会显示生成的路径
Your identification has been saved in/root/.ssh/id_rsa. Yourpublic key has been saved in/root/.ssh/id_rsa.pub.
·添加res_key到服务器
打开刚才生成的.pub文件,复制里面内容 , 在服务器里面输入echo "XXX(.pub里面所有的内容)" >> /root/.ssh/authorized_keys
·禁止密码登陆,并启动ssh_key验证
1、编辑sshd_config文件
vi /etc/ssh/sshd_config
2、禁用密码验证
PasswordAuthentication no
3、启用密钥验证
RSAAuthentication yes PubkeyAuthentication yes
重启服务
RHEL/CentOS系统: service sshd restart Ubuntu系统: service ssh restart debian系统: /etc/init.d/ssh restart
相关文章推荐
- 使用ssh private key 免密码登陆服务器的流程(Amazon 的EMR 采用了此方式登陆服务器)
- ssh免密码登陆 key
- ahjesus SSHkey登陆linux服务器,无需密码,ubuntu
- ssh免密码登陆远程服务器
- 本地 ssh登陆远程服务器不用每次输入密码的方法
- SSH免密码登陆远程服务器配置
- linux 服务器多台ssh无密码自动登陆
- 跨过跳板机,SSH免密码登陆服务器
- linux 禁止帐号密码验证 使用key验证方式登录SSH
- 从零开始构建集群前期准备之---SSH各服务器间无密码登陆
- SSH免密码登陆远程服务器
- 如何不用密码 ssh登陆服务器
- ssh免密码登陆服务器
- SSH 设置无需密码登陆服务器以及解决SSH登陆慢的问题
- ssh 免密码登陆ubuntu腾讯云服务器
- 使用SSH证书(不要密码)登陆远程服务器
- 禁止密码登录,使用SSh-KEY进行登录
- ssh免密码登陆 - 服务器建立信任关系
- linux下无密码ssh登陆服务器
- 服务器之间免密码ssh登陆