I have been using KeePassXC as a password manager for a while and I've been quite happy with it. Today I decided to try to set it up as as ssh agent. The platforms of interest for me are Windows and Linux. I followed this post here from superuser and added my ssh keys to KeePassXC. As advertised, if the database is unlocked and I run ssh-add -l I see the keys from KeePassXC, and when the database is locked, I can't see the keys.
The problem is now in setting the values in ~/.ssh/config correctly. I would like to avoid the agent to just try all available ssh keys. So I added the following two lines to the top of my ~/.ssh/config
IdentitiesOnly yes
PasswordAuthentication no
As described in the other superuser post, I added the public key to the ~/.ssh/config
Host bitbucket
HostName bitbucket.mycompany.com
User Sito
IdentityFile C:\Users\Sito\.ssh\bitbucket.pub
The other post then claims that
sshwill use the correct key from KeePassXC if it's added to agent.
So I ran
> ssh -vvv -T git@bitbucket.mycompany.com
...
debug1: Offering public key: C:\\Users\\Sito\\.ssh\\bitbucket.pub RSA HASH explicit agent
...
debug1: Server accepts key: C:\\Users\\Sito\\.ssh\\bitbucket.pub RSA HASH explicit agent
...
Authenticated to bitbucket.mycompany.com ([IP]:PORT)
...
shell request failed on channel 0
But the moment I try to git clone a repository form our server, I get the following error
> git clone ssh://git@link_to_repo
Load key "C:\\Users\\Sito\\.ssh\\bitbucket.pub": invalid format
git@bitbucket.mycompany.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I again tried to debug this with git config --global core.sshCommand='ssh-vvv'
but the last part before the invalid format message is just
...
debug1: Server accepts key: C:\\Users\\Sito\\.ssh\\bitbucket.pub RSA HASH explicit
debug3: sign_and_send_pubkey: using publickey with RSA HASH
debug3: sign_and_send_pubkey: signing using rsa-sha2-512 HASH
Load key "C:\\Users\\Sito\\.ssh\\bitbucket.pub": invalid format
...
The only difference to the ssh -T here seems to be that instead of explicit agent at the end it just says explicit. Any ideas on how to fix this?
