- 客户端生成公钥和私钥 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- 上传公钥到服务器 scp ~/.ssh/id_rsa.pub root@服务器地址:/root
- 登录到服务器
- 创建.ssh 文件mkdir /root/.ssh
- 创建文件 cd /root/.ssh touch authorized_keys
- 添加私钥 cat id_rsa.pub >> /root/.ssh/authorized_keys
- 添加权限 chmod -R 700 .ssh
# ssh配置文件所在 vim /etc/ssh/sshd_config # 重启ssh systemctl restart sshd.service参考文档
https://developer.aliyun.com/article/641091
注意博文中的chown是更改所有者,chmod才是改权限



