开发者

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.

e.g.:

ssh://<user>@<my-git-server>

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 w开发者_如何学Goindows environment variable or other means to supply the user name for git over ssh?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜