SSH证书配置

On 09/05/2010, in linux, by kilobug

1、添加帐号

useradd test

2、使用test登录

su - test

3、创建公/密钥(会在当前目录生成两个文件:id_rsa和id_rsa.pub)

ssh-keygen -t rsa

4、将生成的id_rsa.pub改名为 authorized_keys,并设置400权限
也可以不改名,但在第6步时需要更改AuthorizedKeysFile的路径

cd ./.ssh/
mv id_rsa.pub authorized_keys
chmod 400 authorized_keys

5、将id_rsa文件下载到本地,删除服务器的id_rsa文件

6、配置/etc/ssh/sshd-config

Protocol 2
ServerKeyBits 1024
PermitRootLogin no  #禁止root登录
 
#RSA认证
RSAAuthentication yes
#开启公钥验证
PubkeyAuthentication yes
#验证文件路径
AuthorizedKeysFile    .ssh/authorized_keys
 
#禁止密码认证
PasswordAuthentication no
#禁止空密码
PermitEmptyPasswords no

7、重启sshd服务

service sshd restart

8、连接工具使用下载的id_rsa文件做证书即可(如提示输入密码,表示该密码为本地证书加密密码,输入即可)

ps: 如果是远程操作,建议先不禁止密码和root登录,待ssh证书登录正常后再禁止!

Tagged with:  

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

无觅相关文章插件,快速提升流量