Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh eval "$(ssh-agent -s) returns Illegal variable name

Why does the eval statement return

Illegal variable name

$ eval "$(ssh-agent -s)"
Illegal variable name.
like image 578
gkmohit Avatar asked Oct 24 '14 02:10

gkmohit


2 Answers

Try $ eval "ssh-agent" instead.

like image 130
Zoë Clark Avatar answered Oct 10 '22 21:10

Zoë Clark


The correct command is

eval $(ssh-agent)

(no quotes!)

Background: ssh-agent sends two lines of code to stdout

SSH_AUTH_SOCK=/tmp/ssh-xxxxxxxxx/agent.nnnn; export SSH_AUTH_SOCK;
SSH_AGENT_PID=22414; export SSH_AGENT_PID;

where /tmp/ssh-xxxxxxxx/agent.nnnn is a file used as a socket to connect to the agent, and the second line contains the PID of the agent process.

$(command) contains those two lines and eval takes them and uses them to create/execute two commands
- result: you have two environment variables telling every process how to connect to the agent.

like image 43
guntbert Avatar answered Oct 10 '22 22:10

guntbert