Why does the eval
statement return
Illegal variable name
$ eval "$(ssh-agent -s)"
Illegal variable name.
Why does the eval
statement return
Illegal variable name
$ eval "$(ssh-agent -s)"
Illegal variable name.
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.
In .csh or .tcsh, the syntax to insert the results of a command into another command like eval is backquote, so the necessary command seems to be
eval `ssh-agent`
That sets the two environment variables and prints the agent PID rather than giving an "Illegal variable name" error
© 2022 - 2024 — McMap. All rights reserved.