查看: 102|回复: 0

[Centos] CentOS 配置无密码登录的实现

[复制链接]

4

主题

0

回帖

0

积分

热心网友

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2011-3-4
发表于 2023-8-5 00:00:00 | 显示全部楼层 |阅读模式

CentOS 配置无密码登录

配置sshd服务 在服务器上修改/etc/ssh/sshd_config:

<!-- lang: shell -->

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#禁止root登录
PermitRootLogin no
 
#指定可以登录的用户
AllowUsers bob alice
StrictModes yes
 
#关闭密码验证
PasswordAuthentication no
 
#打开RSA验证相关设置
RSAAuthentication yes
PubkeyAuthentication yes
 
AuthorizedKeysFile   .ssh/authorized_keys
 
#关闭 GSSAPI验证
GSSAPIAuthentication no

重启sshd服务

生成rsa-keypair 切换到允许ssh登录的用户账户执行如下执行如下命令:

<!-- lang: shell -->

?
1
2
3
4
5
6
#生成key-pair
ssh-keygen
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys
sudo chmod 700 ~/.ssh
restorecon -R -v ~/.ssh

复制刚刚生成的id_rsa文件到本地,一般命名为:server.pem

?
1
ssh -i server.pem username@server

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

原文链接:https://my.oschina.net/ankh2008/blog/189170

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部