ssh 多文件 多站点配置

2022-03-10  本文已影响0人  布衣码农
  1. 进入ssh 目录: <cd ~/.ssh>
  2. 生成新keys <ssh-keygen -t rsa -C "xxx@163.com"> 并输入要生成的文件名 如leaf-go
  3. 将配置文件添加到ssh <ssh-add ~/.ssh/leaf-go>
  4. 创建config文件 <vim config>
# 配置文件
Host leaf.github.com
  HostName github.com
  IdentityFile ~/.ssh/leaf-go
  User xxx@163.com

Host leaf1.github.com
  HostName github.com
  IdentityFile ~/.ssh/leaf-go1
  User xxx@163.com
  1. 测试 <ssh -T git@leaf.github.com>,<ssh -T git@leaf1.github.com>

  2. 进入项目的.git目录找到config文件 <vim config>

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        #在这里把原来的地址替换成ssh config设置的host地址即可
        url = git@leaf.github.com:xxx/x.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main
[user]
        email = xxxx@163.com
上一篇下一篇

猜你喜欢

热点阅读