Search code examples
sshssh-agent

ssh-agent does not work when executing ssh command


I am having trouble with ssh-agent not working...!

My environment:

$ ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020
$ ssh-add -L
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE5FkZ3APf9VLQFHZQV9+JFsNSvY5u33uv5/EWGoQwl5 
$ curl https://github.com/impactaky.keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE5FkZ3APf9VLQFHZQV9+JFsNSvY5u33uv5/EWGoQwl5
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH+nGZTKYUTVOlcJR+OFBE1zDvv5DT2DAcxznTSzXdtr

It does not try to use the ssh-agent key in this state

$ ssh -T -vv git@github.com
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020
...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/impactaky/.ssh/id_rsa
debug1: Trying private key: /home/impactaky/.ssh/id_dsa
debug1: Trying private key: /home/impactaky/.ssh/id_ecdsa
debug1: Trying private key: /home/impactaky/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/impactaky/.ssh/id_ed25519
Enter passphrase for key '/home/impactaky/.ssh/id_ed25519':

Also my settings around ssh can be found at https://github.com/impactaky/useful_ssh-agent.zsh

Thank you for your help.


Solution

  • I finally found it was because this line was added to /etc/ssh/ssh_config.

    IdentitiesOnly yes