私钥登录

1、创建my_keypair.pem文件

内容为ssh-keygen生成的私钥内容,测试发现随便填不行

2、修改权限

chmod 400 my_keypair.pem

通过秘钥生成公钥

ssh-keygen -y -f my_keypair.pem
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDm2CeuTjuI2DtuUlMoLWQnQWVVq2eQk0iSLTN0grNLV3r5gO+Wl0iAOx3XEZOlJlMGH0DNoWrZgFgzYhM/nk/4vDHJkgSyObdckz/+ew4AA+KaQyjSNgexa0ek8D3zDDFHT0Ro2wv+t/zM7mitI1MghQkJ9LhJDKmmJLe/SsGzsqsvfuLpbSjwAluqaYqSb84MMzWF6gKOnGBUwa/QXOvNpmykohhPyAaKIMGDVnSpZG4/Lf/J89HCsJszp+sb0EAHLVlbYwCq2uaDYU2SCjCwYPBdKak3tyvK6GOww09pqWf0I6owWv7vR5rZBmGW28rwqUfjIh8BcZj4hMuhnhFn

3、将公钥放入authorized_keys
4、将私钥pem存入客户端

ssh -i ~/.ssh/my_ssh_keypair.pem root@线上IP

5、测试删除服务器pem,一样可以登录

转载于:https://www.cnblogs.com/jiqing9006/p/10939670.html

你可能感兴趣的:(私钥登录)