0x00 前言

实现ssh服务器免密码登录

0x01 生成密钥

命令行:

ssh-keygen -t rsa #使用rsa加密

在当前用户根目录下~/.ssh/会生成两个文件:id_rsa(密钥文件),id_rsa.pub(公钥文件)

0x02 发送公钥到服务器

1.使用ssh自带工具发送

ssh-copy-id -i ~/.ssh/id_rsa.pub <UserName>@<ServerIP>

2.使用scp发送

scp -p ~/.ssh/id_rsa.pub <UserName>@<ServerIp>:~/.ssh/authorized_keys

0x03 常见问题

如果提示权限不够,修改权限即可

chmod 755 ~/.ssh/
chmod 600 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/known_hosts
Last modification:October 24, 2019
如果觉得我的文章对你有用,请随意赞赏