Table of Contents
1、创建公钥
ssh-keygen
一路回车
2、安装公钥
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
3、修改文件权限
sudo chmod 600 authorized_keys
sudo chmod 700 ~/.ssh
4、修改ssh配置文件
sudo vi /etc/ssh/sshd_config
#下面这个默认开启着
pubkeyAuthentication yes
#最后添加两个
RSAAuthentication yes
permitROOTlogin yes
重启sshd服务
service sshd restart
#或者
systemctl restart sshd
5、转换私钥格式
#安装putty
sudo apt install putty
#转换格式
cd ~/.ssh
puttygen id_rsa -O private-openssh -o newname.pem
7、禁用密码验证登录
下载私钥尝试登录正常后修改以下内容
sudo vi /etc/ssh/sshd_config
找到
#PasswordAuthentication yes
改为
PasswordAuthentication no
重启sshd服务
service sshd restart
#或者
systemctl restart sshd
文章评论