简体   繁体   中英

Problems using GIT w/ SSH key file under Windows

I've problems using GIT with the shell, Visual Studio Code and Visual Studio 2015 (community edition).

Earlier this year I started using GIT with eGit (under Eclipse of course) without any problems. I installed GIT on my server, created a ssh key pair and after a few tests it worked (and still works).

However, now I want to use that GIT on my server with Visual Studio Code and maybe later with Visual Studio 2015.

I got stuck on this issue: GIT trys to use my PPK and asks me for the passphrase (which is emtpy). If I enter a wrong phrase it asks again and continues only if I answer correct (simply enter key). So I think everything is OK till here. But then it asks for the user password for the git-user (the right one btw) on the server and fails. Why?

In the log of my server I can't see any entry about logging in using the key file, only the errors about trying to log in with the password (which is disabled).

If I use putty with that key file I'm able to connect to my GIT server and I also get an entry in the log file. So I'm sure that everything is OK with the server.

What am I missing? I would appreciate any help about that!

Using it with Visual Studio 2015 (I can't solve the issue that it doesn't find libssh when I try to recompile the GIT module following the well known blog entry from Bernardo Pastorelli) or saving the enter key press would be a bonus, however, I would be happy if I could use GIT with key file under Shell / Visual Studio Code at all.

OS: Windows 7 64 bit
GIT 2.10.2.windows.1
VSC: V 1.7.2

TIA!

I'll try to answer the simpler question in your Post:

I would be happy if I could use GIT with key file under Shell

Once, that is done, you can build on it.


Git for windows uses Openssh and therefore will not be able to use the putty PPK file directly.

Two ways forward

Option 1: Convert PPK file to OpenSSH format

Steps to do so:

  1. Open your private key in PuTTYGen
  2. Top menu “Conversions”->”Export OpenSSH key”.
  3. Save the new OpenSSH key when prompted.

To use this new openssh key for your git server, do the following:

Open up Git Bash shell and there edit ~/.ssh/config (create ~/.ssh/ if it does not exist) and define this host:

Host AuxBurgerGitServer
   Hostname whatevers-your-git-remote-is
   User     the-git-user
   IdentityFile ~/.ssh/the-open-ssh-key-exported-before

Test this by doing a ssh -T AuxBurgerGitServer which should not show any errors.

If you go this way, you should use the HOST defined above whenever referring to any repositories on this host. Therefore, for example, to clone a repo you would do something like:

git clone ssh://AuxBurgerGitServer/some-repo-name

Option 2: Configure your GIT to use pageant

You can load your PPK file in pageant and configure GIT to use pageant for authentication.

For this, the only thing you would need is to setup an environment variable like so using:
Control Panel → System → Advanced system settings → Environment variables
(or on Windows 10: Control Panel → Search → Environment variables )

GIT_SSH=c:\Program Files\Putty\plink.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM