Git (SSH) in Visual Studio 2015 Git (SSH) in Visual Studio 2015 git git

Git (SSH) in Visual Studio 2015


No. Visual Studio 2015 (RTM) does not support SSH for Git remotes. This is true even with GitHub repositories using the GitHub plug-in (which - at present - uses the same connection mechanism for Git repositories as any other Git repository using Team Explorer.)

This is regrettable, but there are a handful of reasons why this is not available yet: the short answer is that in our opinion, providing SSH poorly or insecurely is worse than not providing SSH at all, and we would like to be very confident that any SSH implementation we provide is of high-quality.

That said, we are working on it, and making progress. Microsoft is going to begin including OpenSSH in Windows (and is a sponsor of that very fine project). However I cannot make any predictions as to when support might be available.

The GitHub extension is open source, so it's possible that it may be able to use a different connection mechanism and begin supporting SSH before the core Git support in Team Explorer.


Here's some basic instructions for Visual Studio Update 2 and Update 3. See the link in BPas' post for the basic stuff, e.g. you'll need:

  • CMake (I used 3.5.2)
  • libssh2 (I used 1.7.0)
  • libgit2 source (grab the source from VS 2015 as noted in BPas's link)

Build libssh2

  1. I used libssh2 1.7.0. You can use older, but don't as you'll need to fix some build issues in VS2015.
  2. Do the following:

    cd <libssh2 root dir> (e.g. wherever you extracted the source to)mkdir build && cd buildcmake -DCRYPTO_BACKEND=WinCNG -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
  3. Open the resulting libssh2.sln in the build directory

  4. Set the build type to "Release" (this is important!)
  5. Edit the libssh2 project, and set the calling type to __stdcall (e.g. /Gz)
  6. Rebuild all, if successful, the resulting lib will be in build/src/Release/libssh2.lib

Build libgit2

  1. Do the following:

    cd <libgit2 source dir> (e.g. this is wherever you extracted the libgit2 source you got from VS2015's extensions directory, see BPas' link for details)mkdir build && cd buildcmake -DCMAKE_BUILD_TYPE=Release -DSTDCALL=ON -DSTATIC_CRT=OFF -DUSE_SSH=OFF -DLIBSSH2_FOUND=TRUE -DLIBSSH2_INCLUDE_DIRS=<libssh2 root dir>/include -DLIBSSH2_LIBRARIES=<libssh2 root dir>/build/src/Release/libssh2.lib ..
  2. Open the resulting libgit2.sln in the build directory

  3. Set the build type to "Release"
  4. Optional: Patch src/transports/ssh.c to support SSH RSA key authentication, in function request_creds (around line 444):

    if (!t->owner->cred_acquire_cb) {    no_callback = 1;} else {

    with:

    if (!t->owner->cred_acquire_cb) {    if (user) {        const char *val = NULL;        val = getenv("USERPROFILE");        if (val)        {            char *szprivfilename = malloc(strlen(val) + 128);            char *szpubfilename = malloc(strlen(val) + 128);            strcpy(szprivfilename, val);            strcat(szprivfilename, "/.ssh/id_rsa");            strcpy(szpubfilename, val);            strcat(szpubfilename, "/.ssh/id_rsa.pub");            git_cred_ssh_key_new(&cred, user, szpubfilename, szprivfilename, "");            free(szprivfilename);            free(szpubfilename);        }        if (!cred) {            giterr_set(GITERR_SSH, "git_cred_ssh_key_new failed to initialize SSH credentials");            return -1;        }    }    else    {        no_callback = 1;    }} else {

    Note: this patch was grabbed from one the comments in randomswdev's post, seems to work fine from my limited testing.

  5. Rebuild All, output is git2.dll, replace libgit2-msvc.dll in your Visual Studio 2015 extensions directory


Conforming to BPas: for Visual Studio 2015 it is possible to build SSH enabled version. Moreover, i have patch for public/private key auth support:

https://github.com/PROGrand/git2-msvstfs-ssh-patch