When SSH_AUTH_SOCK is not set, keychain --inherit any never finds an existing ssh-agent. It always starts a new one: $ echo $SSH_AUTH_SOCK $ cat .keychain/helium-sh SSH_AUTH_SOCK=/tmp/ssh-AeUWcuq462/agent.462; export SSH_AUTH_SOCK; SSH_AGENT_PID=463; export SSH_AGENT_PID; $ pgrep -U andrex ssh-agent 463 $ keychain --inherit any KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/ Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL * Initializing /home/andrex/.keychain/helium-sh file... * Initializing /home/andrex/.keychain/helium-csh file... * Initializing /home/andrex/.keychain/helium-fish file... * Starting ssh-agent * Inheriting gpg-agent (32013) * Initializing /home/andrex/.keychain/helium-sh-gpg file... * Initializing /home/andrex/.keychain/helium-csh-gpg file... * Initializing /home/andrex/.keychain/helium-fish-gpg file... $ pgrep -U andrex ssh-agent 463 872 In this case keychain should have found the existing ssh-agent, but instead it started a new one. Note that if SSH_AUTH_SOCK is set, then keychain --inherit any does the right thing and inherits the socket for the existing agent. Similarly, keychain --inherit any will start a new gpg-agent even if one is already running, if GPG_AGENT_INFO is unset. For now, the workaround is to use keychain --inherit any-once, which works as described in the man page, although it's not exactly what I want. Thanks, Andrew.
Tested against 2.7.1 and it works for me.
Tested against 2.7.1 on Ubuntu 12.04 and it is *not* fixed. Mark, how are you determining that it's been fixed? yang@db:~$ keychain --version * keychain 2.7.1 ~ http://www.funtoo.org Copyright 2002-2006 Gentoo Foundation; Copyright 2007 Aron Griffis; Copyright 2009-2010 Funtoo Technologies, LLC; lockfile() Copyright 2009 Parallels, Inc. Keychain is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. yang@db:~$ keychain --eval --nogui ~/.ssh/id_rsa * keychain 2.7.1 ~ http://www.funtoo.org * Found existing ssh-agent: 27511 SSH_AUTH_SOCK=/tmp/ssh-THGFdqg27510/agent.27510; export SSH_AUTH_SOCK; SSH_AGENT_PID=27511; export SSH_AGENT_PID; * Adding 1 ssh key(s): /home/yang/.ssh/id_rsa Enter passphrase for /home/yang/.ssh/id_rsa: * ssh-add: Identities added: /home/yang/.ssh/id_rsa yang@db:~$ cat ~/.keychain/db-sh SSH_AUTH_SOCK=/tmp/ssh-THGFdqg27510/agent.27510; export SSH_AUTH_SOCK; SSH_AGENT_PID=27511; export SSH_AGENT_PID; yang@db:~$ ps 27511 PID TTY STAT TIME COMMAND 27511 ? Ss 0:00 ssh-agent yang@db:~$ keychain --eval --nogui ~/.ssh/id_rsa * keychain 2.7.1 ~ http://www.funtoo.org * Found existing ssh-agent: 27511 SSH_AUTH_SOCK=/tmp/ssh-THGFdqg27510/agent.27510; export SSH_AUTH_SOCK; SSH_AGENT_PID=27511; export SSH_AGENT_PID; * Known ssh key: /home/yang/.ssh/id_rsa yang@db:~$ keychain --inherit any --eval --nogui ~/.ssh/id_rsa * keychain 2.7.1 ~ http://www.funtoo.org * Starting ssh-agent... SSH_AUTH_SOCK=/tmp/ssh-nlWOtHX28257/agent.28257; export SSH_AUTH_SOCK; SSH_AGENT_PID=28258; export SSH_AGENT_PID; * Adding 1 ssh key(s): /home/yang/.ssh/id_rsa Enter passphrase for /home/yang/.ssh/id_rsa: