云服务器设置ssh密钥登录

操作步骤

  1. 客户端生成公钥和私钥 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  2. 上传公钥到服务器 scp ~/.ssh/id_rsa.pub root@服务器地址:/root
  3. 登录到服务器
  4. 创建.ssh 文件mkdir /root/.ssh
  5. 创建文件 cd /root/.ssh touch authorized_keys
  6. 添加私钥 cat id_rsa.pub >> /root/.ssh/authorized_keys
  7. 添加权限 chmod -R 700 .ssh

注意:文章中的chown是更改所有者,chmod才是改权限

参考文档

https://developer.aliyun.com/article/641091

原创文章,作者:seabert,如若转载,请注明出处:https://bysjb.cn/ssh.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注