Linux使用ssh公钥登录

linux登录方式:
1. 密码登录:不安全
防火墙配置过滤IP: 麻烦
2、 ssh登录私钥登录:
github原理:
client: ssh-keygen -t rsa ,客户端生成公钥和私钥,在 root/.ssh/
这里写图片描述

把公钥 上次服务端
scp id_rsa.pub [email protected]:/root
这里写图片描述
server端: 公钥保存在哪个用户的目录下,就是用哪个用户登录
mkdir .ssh
cat id_rsa.pub >>/root/.ssh/authorized_keys
chmod 600 authorized_keys
关闭SELinux服务:vi /etc/selinux/config, 把SELINUX=disabled,重启服务器

关闭密码验证:
修改服务器端ssh配置文件: cd /etc/ssh
vi sshd_config:
RSAAuthentication yes : 开启rsa验证
PubkeyAuthentication yes: 是否使用公钥
AuthorizedKeysFile .ssh/authorized_keys: 公钥保存位置
PasswordAuthentication no: 禁止使用密码登录

service sshd restart
ssh [email protected]:登录
这里写图片描述

使用linux私钥, widnow直接连接,xshell直接连接:
这里写图片描述

发布了53 篇原创文章 · 获赞 55 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/dreams_deng/article/details/78968416