The “Permission denied (publickey,gssapi-keyex,gssapi-with-mic)” error you’re encountering suggests that SSH is unable to authenticate using the private key located at:
~/.ssh/id_rsa
Here’s a step-by-step guide to troubleshoot and resolve this:
Step 1) Check If SSH Agent Is Running and Add the Key
Run the following to check if your SSH key is loaded in the agent:
If you see something like:
Add the key manually:
If your key is encrypted, it will ask for the passphrase.
Once added, try connecting again:
Step 2) Check File Permissions
Incorrect file permissions can cause the Permission denied error. Run the following:
Step 3) Verify Key Usage in SSH Config (Optional)
If you are using a custom SSH key or different config, check the SSH config file:
Ensure the following is in place (replace with the correct IP if needed):
Step 4) Test Verbose Mode for Debugging
If it still doesn’t work, run SSH in verbose mode to get more details:
This will help identify any configuration issues.
Step 5) Regenerate SSH Key (if needed)
If the key is corrupted or invalid, regenerate a new key:
Save the new key as
id_rsain the~/.sshdirectory.Add the new public key to the server’s
~/.ssh/authorized_keysfile.
Step 6) Check if Public Key is added on the Server
If you suspect the key is missing on the server, ensure that your public key is added to the ~/.ssh/authorized_keys on the server.
If none of these steps work, send the output of verbose mode to your server administrator.