Linux ssh公钥写入
Linux ssh公钥写入
Cristrik010- 生成密钥对
1 | ssh-keygen -t rsa -b 4096 -f ./id_rsa -C "your_comment" |
当前路径会生成id_rsa和id_rsa.pub
- 上传公钥到靶机
1 | cat /tmp/pub > ~/.ssh/authorized_keys |
- 验证有效性
1 | ssh-keygen -l -f authorized_keys |
- 修改ssh配置
1 | sed -i \ |
- 重启ssh
1 | systemctl restart sshd |
ssh使用私钥连接命令:
1 | ssh -i ./id_rsa \ |