- 进入ssh 目录:
<cd ~/.ssh>
- 生成新keys
<ssh-keygen -t rsa -C "xxx@163.com">
并输入要生成的文件名 如leaf-go - 将配置文件添加到ssh
<ssh-add ~/.ssh/leaf-go>
- 创建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
-
测试
<ssh -T git@leaf.github.com>
,<ssh -T git@leaf1.github.com>
-
进入项目的
.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
网友评论