title: 06.SSH使用证书免密码登录 CreateTime: 2019-06-19 14:08:00 UpdateTime: 2019-06-19 14:08:00 CategoryName: web --- --- title: "06.SSH使用证书免密码登录" date: 2019-06-19T14:08:00+08:00 draft: false tags: ["web"] categories: ["web"] author: "springrain" --- ## 在centos生成公钥/私钥 执行 ssh-keygen -t dsa 默认两次回车 ![](/public/06/document_image_rId9.png) 生成的文件在 /root/.ssh/文件夹下 ![](/public/06/document_image_rId10.png) 执行修改公钥名称为authorized_keys,并修改权限为600 mv id_dsa.pub authorized_keys chmod 600 authorized_keys ![](/public/06/document_image_rId11.png) 重启一下 sshd ![](/public/06/document_image_rId12.png) ## 私钥处理 将生成的 /root/.ssh/id_dsa 下载到windows桌面 使用生成私钥的 ppk文件. ![](/public/06/document_image_rId13.png) ![](/public/06/document_image_rId14.png) 保存私钥为test.apk,文件名自己定义 ![](/public/06/document_image_rId15.png) ## WinSCP使用ppk证书 ![](/public/06/document_image_rId16.png) ## 取消密码认证 修改 vi /etc/ssh/sshd_config 把PasswordAuthentication 修改为 no PasswordAuthentication no 重启ssd即可 service sshd restart