FULL AI ANALYSIS

Permission denied (publickey) when pushing to remote over SSH after adding a new key

Generated Nov 1, 2026, 9:47:23 AM

Analysis summary

Most common causes are (1) key not offered by client (ssh-agent not presenting identity or wrong key filename), (2) public key not installed under the exact account or permissions incorrect on server, or (3) server refusing key due to SSH config or wrong key format. Less likely: server-side restrictions (Match, from=) or using different user/host than expected.

Possible causes

Local SSH agent not offering the new private key (ssh-agent not loaded or identity not added)

8%

Public key not installed in the correct git user's authorized_keys path or installed with wrong permissions/format

7%

SSH client using a different key filename or host alias; config mismatch (Host entry overrides IdentityFile)

5%

Server-side SSH configuration rejects key because of 'from=' option, command=, or mismatched key type

3%

Suggested fixes

1

Diagnostic step 1

Run ssh -vvv git@git.example.com and examine the offered identities lines (look for 'Offering public key' and which key file is referenced). Result meaning: If the client does not show 'Offering public key' for your new key, it isn't being offered — add it with ssh-add or configure IdentityFile in ~/.ssh/config. If it is offered but server rejects, the server either lacks that public key or rejects it.

2

Diagnostic step 2

On the server, check ~git/.ssh/authorized_keys contains the exact public key text (no extra whitespace) and ensure ~git/.ssh is 700 and authorized_keys 600; also check ownership is git:git. Result meaning: If authorized_keys missing the key or permissions/ownership incorrect, SSH will ignore it. Fixing ownership/permissions and re-testing should allow authentication. If key is present and perms OK, move to server-side logs.

3

Diagnostic step 3

Tail the SSH server auth logs (e.g., sudo tail -F /var/log/auth.log) while attempting an ssh connection from the client. Result meaning: If the server log shows 'authentication refused' and indicates which key or why, that narrows the issue: 'key type mismatch', 'user not found', or 'authorized_keys invalid'. If logs show no attempt for that user/host, client may be connecting to different host or user.

4

Diagnostic step 4

Check ~/.ssh/config for Host entries that may override IdentityFile or User; explicitly run ssh -i ~/.ssh/id_ed25519 -vvv git@git.example.com to force the key. Result meaning: If forcing -i makes it work, then your SSH config prevented the key from being used before — update config. If forcing -i still fails, problem likely server-side or key pair mismatch.