SSH Agent Config Fragment

SSH Agent

This is the fragment to make sure the ssh-agent is running when you open the terminal.

Put this in ~/.config/fish/conf.d/.

if status --is-interactive
    keychain --eval --quiet --quick id_rsa | source
end

The documentation for the status comand says that is-interactive is actually a sub-command (not an option, although I'm calling it like it is one) and that it:

Returns 0 if fish is interactive - that is, connected to a keyboard.

Which is an oddly unintuitive description. I think it means that it won't pass the conditional if I try to run the fragment as a function… I can't remember why I used it, exactly ,but I think it's something you need if you want it to be loaded when you login.

Although the name keychain makes it sound like it's a general password manager, according to the man-page it's meant specifically to manage the ssh-agent. It will check if you already have an ssh-agent running and only start one if you don't. This way you don't end up starting one for every screen you open up.

The --eval option sends the SSH-Agent message to stdout, --quiet suppresses other messages, --quick tells it to use a running ssh-agent if it finds one without verifying the keys and then we pipe it to source to load the environment.

Links