git本地设置,GitHub添加ssh key,使用别名登录服务器

53 阅读1分钟

一、Git本地设置

  1. git config --global user.name "github用户名(要加"",并且写在""里面)"
  2. git config --global user.email "github邮箱(要加"",并且写在""里面)"
  3. git config --global push.default simple
  4. git config --global core.quotepath false
  5. git config --global core.editor "code --wait"
  6. git config --global core.autocrlf input

二、GitHub添加ssh key

  1. 生成密钥: ssh-keygen -t ed25519 -C "github邮箱(要加"",并且写在""里面)"
  2. 密钥路径: C:\Users\YourUsername.ssh
  3. 上传公钥: 文件后缀为.pub的是公钥,将内容全部复制
  4. 测试连接: ssh -T git@github.com

使用别名登录服务器

  1. 在.ssh文件夹中创建config文件(没有后缀名)
  2. 文件格式如下
Host 别名
    HostName 服务器ip
    User 服务器用户名
  1. ssh-copy-id 别名
  2. ssh 别名(无需输入密码)