linux系统使用密钥验证远程登录
警告
本文最后更新于 2020-05-30 17:09,文中内容可能已过时。
1.按照以下提示输入即可
root@localhost ~]# ssh-keygen -t rsa //采用rsa的加密方式的公钥/私钥 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): //询问输入私钥和公钥放在那里,直接回车 Enter passphrase (empty for no passphrase): //这里可以给私钥设置密码 Enter same passphrase again: //提示再次输入私钥密码,再次回车
2.进入密钥目录
[root@localhost ~]# cd /root/.ssh
3.ls查看文件可以看到以下两个文件
[root@localhost .ssh]# ls id_rsa id_rsa.pub
4.导入公钥到认证文件中
[root@localhost .ssh]# mv id_rsa.pub authorized_keys
5.给认证文件修改权限600
[root@localhost .ssh]# chmod 600 authorized_keys
6.将配置文件中PasswordAuthentication yes 改为 PasswordAuthentication no //禁止使用密码远程登录系统
[root@localhost .ssh]# vim /etc/ssh/sshd_config
请我喝杯水

