After moving your SSH keys to a new system, you may get the following error message when connecting to a remote system which would normally accept your SSH keys.
➜ /opt ssh [email protected]
sign_and_send_pubkey: signing failed for RSA "/home/user/.ssh/id_rsa" from agent: agent refused operation
[email protected]: Permission denied (publickey).
That specific error usually means your SSH agent knows about your key, but it’s having trouble actually using it to sign the authentication request. This often happens because the key hasn’t been properly “unlocked” or the agent’s communication has become stale.
The most common cause is that the SSH agent is running but doesn’t have the identity “loaded” with the correct permissions. Running this command will prompt you for your passphrase and re-add the key to the agent.
Add the key
First add the key to the agent.
ssh-add /home/user/.ssh/id_rsa
Set proper file permissions
Your file permissions can’t be too permissive.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa