On Fri June 10th 2022 at 17:26, <[email protected]> wrote:
> In my (seemingly unending) quest to understand ssh, I've come across a
> document that calls for running =eval 'ssh-agent'= from a command line.
>
> I wondered why, as I thought I would get the same result from just running
> =ssh-agent=, but the results are different -- see below:
>
> $ eval `ssh-agent`
> Agent pid 23929
>
> $ ssh-agent
> SSH_AUTH_SOCK=/tmp/ssh-uLqQ9VWX0RL7/agent.23932; export SSH_AUTH_SOCK;
> SSH_AGENT_PID=23933; export SSH_AGENT_PID;
> echo Agent pid 23933;
>
> Can anybody on here explain what is going on / why?
>
The command "ssh-agent" returns 3 lines. The "eval `ssh-agent`" command
makes bash (or any other sh-compatible shell) runs those three lines as
if they
had been typed. Hence it defines two variables (SSH_AUTH_SOCK and
SSH_AGENT_PID) and prints "Agent pid 23933".
Greetings,
Loïc