ssh authentication problem with git submodules in windows
I am using git Microsoft Windows. The git is working fine in my windows desktop. I may clone, push and pull from remote origin git repository via ssh.
When I use the git with submodule, the .gitmodules file contain this:
[submodule "build"] path = build url = ssh://<my-git-server>/srv/repos/git/build.git [submodule "core"] path = core url = ssh://<my-git-server>/srv/repos/git/core.git
As the git repository is shared in network, the url won’t contain user name.
If my ssh user name match with my windows account user name, then I may perform git operation that involve ssh accessing the git server without problem.
However, some developer’s windows account name doesn’t exist in ssh service, and those ssh git operation asking password will fail.
Is there any option to setup in windows environment variable or other means to supply the user name for git over ssh?
One Solution collect form web for “ssh authentication problem with git submodules in windows”
If you are running OpenSSH, you have two options.
Tell Git to execute ssh with a specific username. At a UNIX shell prompt (bash, sh) you can run the following before running Git:
export GIT_SSH="ssh -l myusername"
Alternatively, you can set the Windows environment variable
GIT_SSHto the above value.
See the “Environment Variables” section of
git help gitfor details.
This approach has the advantage of only affecting Git, but that username will be used for every other Git repository accessed over ssh.
Add the following lines to your
Host my-git-server User myusername
ssh_configdocumentation for details.
You’ll have to determine what msysGit’s ssh thinks your home directory is. You might need to set your
HOMEenvironment variable to
%HOMEDRIVE%%HOMEPATH%. Alternatively, you can configure the
GIT_SSHenvironment variable to pass the
-F path_to_your_ssh_configoption to
This approach has the advantage of only affecting ssh access to my-git-server, but it affects non-Git ssh logins to my-git-server as well (which you probably want).