funtoo / keychain

keychain ssh-agent front-end
http://www.funtoo.org
GNU General Public License v2.0
748 stars 104 forks source link

Question: what is the canonical way to update config without spawning new agents? #108

Open stsquad opened 5 years ago

stsquad commented 5 years ago

Running keychain-2.8.2 I'm finding it hard to ensure all configurations are written out. I've had to hand-code detecting of the forwarded agent in fish shell like this:

         if test -S $SSH_AUTH_SOCK;
            keychain -q -k all --inherit any --agents ssh --systemd
            # keychain doesn't seem to save the parameters so lets do it here
            echo "set -e SSH_AUTH_SOCK; set -x -U SSH_AUTH_SOCK $SSH_AUTH_SOCK;" > $HOME/.keychain/$HOSTNAME-fish
            echo "set -e SSH_AGENT_PID;" >> $HOME/.keychain/$HOSTNAME-fish
            set report "Using forwarded ssh agent"
        else
            keychain -q -k others --clear --agents ssh --systemd
            set report "Using local ssh agent"
        end

But for subsequent calls to refresh the environment fail when called from emacs because HOSTNAME-sh hasn't been written to. Surely this is something that keychain should be doing when it inherits the environment?

stsquad commented 5 years ago

I thought I had this sorted with the following:

            keychain -q -k all --inherit any --agents ssh --systemd
            # the second call ensures we update all the saved configs
            # this seems to behave differently on differnt machines
            keychain -q --inherit any

But I was getting different behaviour on two machines with the same keychain. It turns out once of the machines had SSH_AGENT_PID set in the environment and that was enough to cause keychain -q --inherit any to spawn a new ssh-agent on the second machine.

mrl5 commented 2 years ago

hello @stsquad - if you'd like to report a bug kindly use https://bugs.funtoo.org/

you can also reach us on Discord - for more info check https://www.funtoo.org/Welcome