【发布时间】:2017-07-02 14:03:08
【问题描述】:
我已经按照tutorial为多个github账户设置了SSH密钥。
但我不断收到错误
ssh: Could not resolve hostname github-psdtowordpresspro.com: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
后续步骤:
- 已创建 SSH 密钥:
id_rsa_psdtowordpresspro.pub文件位于.ssh目录中。 (请注意,这个文件夹之前不存在。所以我必须创建一个)
使用语法ssh-keygen -t rsa -C "your-email-address"
将 SSH 密钥添加到我的第二个 github 帐户
-
添加密钥
ssh-add ~/.ssh/id_rsa_COMPANY
-
使用命令创建了
.config文件触摸 ~/.ssh/config vim 配置
这是我在.config 文件中编写的代码
Host github-regipheirim
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_psdtowordpresspro
这正是教程中提到的方式。
然后我将远程原点添加为
git remote add origin git@github-psdtowordpresspro.com:regipheirim/regi.git
但是当我尝试推送时,它显示“无法解析主机名”的错误。
这里是截图
Git remote connection setting of second account
项目的.config 文件
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = git@github-regipheirim:regipheirim/regi.git
fetch = +refs/heads/*:refs/remotes/origin/*
[user]
name = regipheirim
email = p.regidev@gmail.com
也尝试过(基于 TJL 在评论部分的建议)
git remote set-url origin git@github.com:regipheirim/regi.git
但是当我试图用
git push origin master
我再次收到错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
所以任何人都可以帮助我解决我在这里做错的事情。我只是花了整个星期天才弄清楚。
【问题讨论】:
-
GIT_SSH_COMMAND="ssh -vvv"