密钥安装登录

ssh密钥登录详解

1)ssh-keygen -t rsa (在服务器端生成公钥、私钥对)【命令后会让输入密钥名称如果不写名称即默认id_rsa、id_rsa.pub ,然后公钥,密钥密码,然后就会生成】 

~/.ssh/id_rsa (生成后的私钥位置) 
~/.ssh/id_rsa.pub (生成后的公钥位置)
2)使用多个公钥、秘钥可以追加到
more ./id_rsa.pub >> ~/.ssh/authorized_keys (多个公钥追加)
more ./id_rsa >> ~/.ssh/id_rsa (多个秘钥追加)
3)然后重新启动sshd就行了.
service sshd restart

<进阶>
禁止口令登录

vi /etc/ssh/sshd_config
PasswordAuthentication yes 改为 PasswordAuthentication no
#PasswordAuthentication yes
PasswordAuthentication no

标签: none

评论已关闭