When I want to start (or restart) ssh-agent
, it gives me a few commands that I should run by doing eval $(ssh-agent)
. Of course this fails for fish, since it gives syntax for bash or csh.
The commands look like:
SSH_AUTH_SOCK=/var/folders/v4/c116f_790t7g58lh3jbr7_vm0000gq/T//ssh-L95xhmGl9FZo/agent.36846; export SSH_AUTH_SOCK;
SSH_AGENT_PID=36847; export SSH_AGENT_PID;
echo Agent pid 36847;
or for csh:
setenv SSH_AUTH_SOCK /var/folders/v4/c116f_790t7g58lh3jbr7_vm0000gq/T//ssh-Tf8etHZfP9k3/agent.36873;
setenv SSH_AGENT_PID 36874;
echo Agent pid 36874;
The csh version runs without complaint when I do eval (ssh-agent -c)
, and then echo $SSH_AGENT_PID $SSH_AUTH_SOCK
gives the expected output. However, new shells do not keep those variables. What does setenv
do? clearly it set
s variables somehow, but it's nowhere in the documentation. If I start a new terminal, the variables are lost, so I'm not sure they're exported?
I just found that setenv
is a fish function, with definition set -gx
, so I suppose it sets the variable as a global
variable and exports it. I don't have a good understanding of the variable scope, so is the the appropriate thing for the ssh-agent
variables?
For context, I'm doing this based on instructions at github. I've been using an ssh key for github for years and never did the ssh-agent
or ssh-add
thing, but I noticed it while setting up on a new computer. It also seems that os x is running ssh-agent on its own (or something else I set up long in the past), because there exists $SSH_AUTH_SOCK
already. So maybe running this is not important? ssh-add
does run without complaint even without running ssh-agent
.
type setenv
functions setenv
, see my edit.type
is nice, though. It seems to be some combination ofwhich
andfunctions
.