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:

  • Get the latest commit in a repository with JGit
  • git: Trying to re-create same repo but with some different files
  • Git History and Rebase issue
  • How to use git filter.gitignore.clean to filter both branches during a diff
  • Repo sync fails to initialize CM13 work tree
  • git log --stat relative to subfolder
  • [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?

  • Shortcuts for git commands
  • How can I set merge “No Fast Forward” as the default in TortoiseGit?
  • git: rebase (after merge) gives only conflicts
  • How to quickly mark resolution having conflicts during rebase?
  • Reset local repository branch to be just like remote repository HEAD
  • Is there a way in git to checkout all files except 1 or 2?
  • One Solution collect form web for “ssh authentication problem with git submodules in windows”

    If you are running OpenSSH, you have two options.

    1. 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_SSH to the above value.

      See the “Environment Variables” section of git help git for details.

      This approach has the advantage of only affecting Git, but that username will be used for every other Git repository accessed over ssh.

    2. Add the following lines to your ~/.ssh/config file:

      Host my-git-server
        User myusername

      See the ssh_config documentation for details.

      You’ll have to determine what msysGit’s ssh thinks your home directory is. You might need to set your HOME environment variable to %HOMEDRIVE%%HOMEPATH%. Alternatively, you can configure the GIT_SSH environment variable to pass the -F path_to_your_ssh_config option to ssh.

      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).

    Git Baby is a git and github fan, let's start git clone.