[英]Pushing git commit from remote server through SSH: Permission denied (publickey). fatal: Could not read from remote repository
I am connected through SSH to my machine at work, on which I am developing some code.我在工作时通过 SSH 连接到我的机器,我正在开发一些代码。
I have committed some changes, which I would now like to push, however, I get:我已经提交了一些更改,现在我想推动这些更改,但是,我得到:
Permission denied (publickey).
fatal: Could not read from remote repository.
AFAIK this issue occurs when the SSH keys for the git repo are not properly set up. AFAIK 当 git repo 的 SSH 密钥未正确设置时,会出现此问题。
Thing is, I can push and pull no problems when I am physically at work using the computer.事实是,当我使用计算机进行身体工作时,我可以毫无问题地推拉。
The problem only occurs when I try to do so through a SSH connection.仅当我尝试通过 SSH 连接执行此操作时才会出现此问题。
Any ideas what's going on here?任何想法这里发生了什么?
Through an SSH connection, you might not have the same environment variables than directly connected on your machine.通过 SSH 连接,您可能没有与直接连接到计算机上的环境变量相同的环境变量。
Check what, in your SSH session, $HOME refers to, and if you see your $HOME/id_rsa
/ id_rsa.pub
SSH private/public key files.检查在您的 SSH 会话中 $HOME 指的是什么,如果您看到
$HOME/id_rsa
/ id_rsa.pub
SSH 私钥/公钥文件。
Then do a ssh -Tv github.com
(replace github by the actual target server name) to see what is going on.然后执行
ssh -Tv github.com
(用实际目标服务器名称替换 github)以查看发生了什么。
Thanks to @VonC for leading me to the solution, which was re-generating the ssh keys.感谢@VonC 引导我找到重新生成 ssh 密钥的解决方案。 Unfortunately, simply renaming them to the default (id_rsa.pub and id_rsa) didn't work.
不幸的是,简单地将它们重命名为默认值(id_rsa.pub 和 id_rsa)是行不通的。 This is more of a work-around than a solution, but it seems that in my case going in through ssh requires the git ssh keys to hold the default names.
这与其说是解决方案,不如说是一种变通方法,但似乎在我的情况下,通过 ssh 进入需要 git ssh 密钥来保存默认名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.