Linux SSH 使用安全秘钥登录
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux SSH 使用安全秘钥登录,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1845字,纯文字阅读大概需要3分钟。
内容图文
1,客户端生成密钥对
#ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):按回车键或设置密钥的存储路径 Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase): 直接按回车键或设置密钥的密码 Enter same passphrase again: 再次按回车键或设置密钥的密码 Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 40:32:48:18:e4:ac:c0:c3:c1:ba:7c:6c:3a:a8:b5:22 root@hello The key's randomart image is: +--[ RSA 2048]----+ |+*..o . | |*.o + | |o* . | |+ . . | |o.. S | |.. + | |. = | |E+ . | |+.o | +-----------------+
2,把客户端主机中生成的公钥文件传送到远程主机:
# ssh-copy-id 192.168.10.10 The authenticity of host '192.168.10.20 (192.168.10.10)' can't be established. ECDSA key fingerprint is 4f:a7:91:9e:8d:6f:b9:48:02:32:61:95:48:ed:1e:3f. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.10.10's password:此处输入远程服务器密码 Number of key(s) added: 1 Now try logging into the machine, with: "ssh '192.168.10.10'" and check to make sure that only the key(s) you wanted were added.
3,对服务器进行设置,使其只允许秘钥验证,拒绝口令验证方式,修改配置文件后要重启sshd服务。
[root@hello ~]# vim /etc/ssh/sshd_config ………………省略部分输出信息……………… 74 75 # To disable tunneled clear text passwords, change to no here! 76 #PasswordAuthentication yes 77 #PermitEmptyPasswords no 78 PasswordAuthentication no 79 ………………省略部分输出信息……………… [root@hello ~]# systemctl restart sshd
4,在客户端登录到服务器,此时无需输入密码即可成功登陆
内容总结
以上是互联网集市为您收集整理的Linux SSH 使用安全秘钥登录全部内容,希望文章能够帮你解决Linux SSH 使用安全秘钥登录所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。