Issue
Backstory: I am working on a Windows PC that is connected to a Ubuntu laptop via SSH. This laptop is connected to the company network via VPN. Company uses gitea (if that's relevant).
The problem: While attempting to use git from PC (Windows Terminal, VS Code terminal, VS Code git features) I am getting a Permission denied (publickey)
message. Everything works fine if I'm trying to do the same from a terminal on the laptop.
Similarly, pipenv install
fails on installing dependencies from the repository.
Visualization :)
[Laptop]: git pull
results in a successful pull
[PC --ssh-> Laptop]: git pull
results in a permission denied
No such things happen when I try to access my private github repos with PC ssh'd to my other computer. I have even tried adding a key generated on PC to the authorized git keys with no improvement whatsoever.
EDIT: @VonC's answer made me run a verbose ssh
connection and revealed that ssh-agent wasn't running for my remote connection and only offered keys from ~/.ssh/
that started with id_
while my git key had a git_
prefix.
Solution
Test first, from a simple CMD:
ssh -Tv [email protected]
That will display the path ofthe keys SSH will try to use.
Check for instance if you do have a %USERPROFILE%\.ssh\id_rsa
key, with its .pub
content registered to your GitHub account.
Note on my own company laptop, connected by VPN, I would not be able to perform an Egress SSH operation: SSH is disabled for egress.
As the OP seseikelele notes in the comments:
Running verbose SSH to the git server revealed that shell sessions from my PC didn't use keys provided by ssh-agent and just tried to offer keys wih
id_
prefix.Starting the agent allowed Git to get authenticated on that one shell instance.
Answered By - VonC