- 1 year ago
On Windows 10 that is well configured with native OpenSSH's ssh-agent, how to have an implementation of git use the ssh-agent configured?
If your Windows 10 system is already configured with the native OpenSSH's ssh-agent and you want Git to use the configured ssh-agent for authentication, you can follow these steps:
Check if the ssh-agent is running:
Open a Command Prompt or PowerShell window and run the following command:ssh-agent
If the ssh-agent is not running, it will start and display the necessary environment variables to set up the agent.
Set up the ssh-agent environment variables:
If the ssh-agent is running, it will display output like this:bashSSH_AUTH_SOCK=/tmp/ssh-something/agent.something; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1234; export SSH_AGENT_PID;
echo Agent pid 1234;
Take note of the values for
SSH_AUTH_SOCK
andSSH_AGENT_PID
.Set the environment variables for the current shell:
In the same Command Prompt or PowerShell window, set the environment variables for the current session using the provided values:arduinosetx SSH_AUTH_SOCK "/tmp/ssh-something/agent.something"
setx SSH_AGENT_PID "1234"
Restart the terminal or open a new terminal window:
The environment variables should now be set for the current shell, and Git will be able to use the ssh-agent for authentication.Test Git with ssh-agent:
Now, you can test Git with the ssh-agent by running a Git command that requires SSH authentication, such as cloning a Git repository using thegit clone
command with an SSH URL.
If the above steps do not work or you encounter any issues, make sure that your Git installation is using the correct version of the OpenSSH client. By default, modern Git for Windows installations come with Git's own implementation of SSH, so you might need to configure Git to use the system's OpenSSH client.
To configure Git to use the system's OpenSSH client, you can do the following:
Find the path of the system's OpenSSH client (ssh.exe):
Open a Command Prompt or PowerShell window and run:bashwhere ssh
It should show you the path to the OpenSSH client provided by the system.
Configure Git to use the system's ssh.exe:
Set theGIT_SSH
environment variable to the path of the system's ssh.exe. For example, if the system's ssh.exe is located atC:\Windows\System32\OpenSSH\ssh.exe
, run:arduinosetx GIT_SSH "C:\Windows\System32\OpenSSH\ssh.exe"
Restart the terminal or open a new terminal window:
The environment variable should now be set, and Git should use the system's ssh-agent and ssh.exe for authentication.
Please note that if you are using a Git GUI client, it might have its own settings for SSH authentication, so you might need to configure it separately to use the system's ssh-agent.