1

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Mr Squid
  • 1,196
  • 16
  • 34

2 Answers2

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Riiiight, I actually called them bb_priv and bb_priv.pub respectively. I'll test if renaming the key files solves it – Mr Squid Feb 07 '20 at 07:26
  • @MrSquid if those keys are called differently, check if you have an `~/.ssh/config` file, and if the ssh URL you are using to push (git remote -v) is `:/` – VonC Feb 07 '20 at 07:33
  • No such file. Should I create one? – Mr Squid Feb 07 '20 at 07:37
  • 1
    @MrSquid For testing, rename your keys first (if you don't already have `id_rsa(.pub)` files). If not, yes: follow https://stackoverflow.com/a/55274407/6309. – VonC Feb 07 '20 at 07:39
0

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.

Mr Squid
  • 1,196
  • 16
  • 34