centos7 证书登录

    |     2017年11月21日   |   学习偶记   |     评论已关闭   |    6032

A、服务器上 ssh-keygen -t rsa生成私钥和公钥【在本地也可以用putty的密钥生成工具来完成】,在本例中我没有输入密码。

centos证书登录

centos证书登录

B、导入公钥:cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

设置权限:chown -R 0700 ~/.ssh

公钥权限:chown -R 0644 ~/.ssh/authorized_keys

目录权限:chown -R root:root /root

开通了SEliunx,需要执行:restorecon -R -v /root

以上是root的证书生成。其他用户证书生成请替换root。。。也许目录会在home/用户名

centos-ssh-证书-2

centos-ssh-证书-2

C、打开winscp,用编辑工具修改/etc/ssh/sshd_config

RSAAuthentication yes  #RSA验证开启
StrictModes no #如果StrictModes为yes必需保证存放公钥的文件夹的拥有与登陆用户名是相同的.
PubkeyAuthentication yes # 允许PubkeyAuthentication认证
AuthorizedKeysFile .ssh/authorized_keys #公钥证书存放的位置

D、重启ssh服务:

systemctl restart sshd.service

E、从证书目录,将id_dsa复制到本地

cd ~/.ssh

cp id_dsa /home/wwwroot #根据自己的实际情况,复制到可以下载的目录

F、本地putty设置证书

首先用puttygen.exe生成ppk证书,然后配置putty的证书登录即可。记住save session 步骤我就不描述了,直接上图。

centos-ssh-证书-登录

centos-ssh-证书-登录

centos-ssh-证书-登录

centos-ssh-证书-登录

centos-ssh-证书-登录

centos-ssh-证书-登录

G、winscp配置图示

winscp证书登录

winscp证书登录

H、登录成功后,修改/etc/ssh/sshd_config ,把允许密码登录选项去掉。

PasswordAuthentication no

I、重启SSH服务
systemctl restart sshd.service 或者 /etc/rc.d/init.d/sshd restart

本文转自:http://blog.csdn.net/long690276759/article/details/53535464 有改动。

噢!评论已关闭。