服务器小技巧

服务器操作小技巧

SSH免密登录服务器

  1. 在本地(非服务器)终端输入命令生成密钥对 ssh-keygen -t rsa
  2. 将公钥复制到远程主机 ssh-copy-id 用户名@服务器地址, ssh-copy-id 会将公钥写到远程主机的 ~/.ssh/authorized_key文件中
  3. 本地ssh 用户名@服务器地址 免密码登录

生成ssh公钥用于各种Git服务

  1. ssh-keygen -t ed25519 -C "xxxxx@xxxxx.com" 邮箱名随便起, ed25519是公钥名字防止和rsa重复
  2. 三次回车
  3. cat ~/.ssh/id_ed25519.pub查看文件内容或者通过open打开目录去找
  4. 复制 ed25519.pub里面的内容贴到Git网站上面的SSH
Author: XavierShi
Link: https://blog.xaviershi.com/2021/04/20/服务器小技巧/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.