vanderwaal
vanderwaal

Reputation: 428

eval is not recognised on Windows

I am beginner and I'm trying to connect my GitHub profile with my local machine.

I'm following the steps but my git cmd does not recognise eval. I have generated a key and am trying to add an SSH key to the ssh-agent.

This is the message I get:

'eval' is not recognized as an internal or external command, operable program or batch file.

The command I run is:

eval "$(ssh-agent -s)"

Upvotes: 10

Views: 18066

Answers (1)

Peter Badida
Peter Badida

Reputation: 12169

You are running the command in the wrong console.

Open Powershell1, Git Bash console or WSL bash - depending on how you installed Git - because this is just Command Prompt (cmd.exe) which doesn't support even the syntax you're trying (Bash).

Or alternatively, ensure ssh-agent's folder is in the PATH environment variable. Then you'll be able to call it even from a different console, that is, a part of the eval $(ssh-agent -s) command.

What that part does is nevertheless incompatible with the Command Prompt console:

     -s      Generate Bourne shell commands on stdout.  This is the default if
             SHELL does not look like it's a csh style of shell.

and outputs something like this:

SSH_AUTH_SOCK=/tmp/ssh-jR0WcW41z0yX/agent.1918430; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1918431; export SSH_AGENT_PID;
echo Agent pid 1918431;

which might be worked around by using Command Prompt's SET command like this:

set SSH_AUTH_SOCK=c:\some\path\agent.1918430
set SSH_AGENT_PID=<the number you got>

and then run the commands following that eval $(ssh-agent -s) instruction.


1 PowerShell instance that comes up when opened from the original GitHub toolkit (containing also Git Bash), which preloads some aliases or other functionality. eval itself might not be present in the clean instance of PowerShell. When not available, use Invoke-Expression.

Upvotes: 10

Related Questions