Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

设置centos8stream的证书登录方式[0]

Posted on 2023年11月14日2025年5月6日 by
  • 简介

centos的常用登录方式包括ssh的密码登录和证书登录

1)密码登录:

登录只是密码的一个应用场景之一. 但是密码常见的风险在于, 一是可能泄露, 二是被破解的风险,常见的处理措施包括denyhosts和failban进行加强。

2)证书登录:

这里说的证书其实就是密钥. 在非对称加密中, 密钥分为公钥和私钥. 私钥, 即密钥所有人持有. 公钥则公布给他人. 公钥和私钥成对使用, 互相解密. 公钥加密数据只能用私钥解密; 私钥加密则只能用公钥解密(验证)

证书登录原理:密钥对生成后, 公钥存储于远程服务器. 登录时远程服务器向客户端发送随机字符串, 客户端以私钥加密后返回服务器, 服务器再以公钥解密. 解密成功则证明客户端合法, 允许登录。

  • 部署过程

1)SSH的公钥和私钥

ssh-keygen -t rsa #生成密钥对
cd /root/.ssh/  #默认位置
cat id_rsa.pub >> authorized_keys #生产可以本地登录的key

原因如下:/etc/ssh/sshd_config文件默认设定

2)SSH配置文件,支持使用证书登录

sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g'  /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g'  /etc/ssh/sshd_config
sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g'  /etc/ssh/sshd_config
sed -i 's/#StrictModes yes/StrictModes no/g'  /etc/ssh/sshd_config

以上设置实现只允许证书登录,并且禁止密码登录。

systemctl restart sshd #重启ssh服务

3)Xshell 7登录测试

测试通过

4)linux登录

cd /root
chmod 600 id_rsa1
ssh -i id_rsa1 root@10.10.10.152

测试通过

补充问题

1)证书的权限问题

 

参考资料:

  1. https://blog.csdn.net/uisoul/article/details/85237732
  2. https://blog.csdn.net/wanghailong_qd/article/details/90389494

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT