CentOS 配置无密码登录的实现
程序员文章站
2023-11-11 13:17:40
centos 配置无密码登录
配置sshd服务 在服务器上修改/etc/ssh/sshd_config:
...
centos 配置无密码登录
配置sshd服务 在服务器上修改/etc/ssh/sshd_config:
<!-- lang: shell -->
#禁止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 -->
#生成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
ssh -i server.pem username@server
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!