简体   繁体   中英

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.
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.

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.
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.

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.

Then do a ssh -Tv github.com (replace github by the actual target server name) to see what is going on.

Thanks to @VonC for leading me to the solution, which was re-generating the ssh keys. Unfortunately, simply renaming them to the default (id_rsa.pub and id_rsa) didn't work. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM