Resolving Mercurial SSH Connection Issues
The Problem
If you get below error when trying to pull or update your Mercurial repository, chances are your SSH agent didn’t forward your key:
remote: Permission denied (publickey).
abort: no suitable response from remote hg!
The Solution
Checking SSH Agent Status
To make sure your SSH agent have access to your key run below command:
ssh-add -l OR ssh-add -L
If you get “Could not open a connection to your authentication agent.” message, that means your key didn’t get forwarded by your agent.
Verifying SSH Agent
First make sure SSH agent is running:
echo $SSH_AUTH_SOCK
The output shouldn’t be empty when running the above command.
Adding SSH Key
To add your key to SSH agent run below commands:
eval $(ssh-agent)
ssh-add [your-key]
Configuring SSH Host
Alternatively, you can add details of your host to the ssh config file. Add following lines to ~/.ssh/config
file:
Host arbitrary-host-name
User user-name
ForwardAgent yes
HostName IP-address