我在远程访问的机器上使用 git (github) 时遇到了一些问题。我正在通过 ssh 从家里登录到我的工作计算机,例如
me@home$ ssh me@work
之后,我尝试通过家庭在我的工作计算机上对 github 执行 pull 或推送请求,例如
me@workViaHome$ git pull origin branch
之后我收到错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我尝试使用以下方法从我的工作计算机加载 ssh key :
me@workViaHome$ eval "$(ssh-agent -s)"
me@workViaHome$ ssh-add ~/.ssh/id_rsa
但仍然没有运气。当我在我的工作计算机上时,我可以毫无问题地向 github 发出请求;因此,由于我的 ssh session ,我的 ssh key 状态似乎存在问题。
谢谢你的帮助!
最佳答案
如果没有在配置中另外指定或者如果 ssh-agent
SSH 使用默认 key 不提供任何其他 key 。
如果您在非标准位置使用 key ,该 key 已添加到 gnome-keyring
,您可能会注意到这种行为,因为 gnome-keying
仅针对图形 session 启动,但不适用于 ssh
session 。
当然,您可以通过在 ~/.ssh/config
中正确配置此 key 来解决此问题。在工作电脑上。只需添加
Host github.com
IdentityFile ~/.ssh/path_to_key
IdentitiesOnly yes
关于git - 通过远程机器连接到 github 的 ssh key 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45137676/