8

I'm a quite beginner in using Git (cmd, and UI clients),
I installed Git extensions, set up all requirements.
When I tried to connect to a repository on BitBucket, private account (I used my own ppk that I have on my computer), I get this message:

enter image description here

When I click on Yes I'm presented with a Git window:

enter image description here

Can anyone help me get over this so I can clone repositories?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
mshwf
  • 7,009
  • 12
  • 59
  • 133
  • This is a normal warning that you should expect when you have not connected to the remote device before. – Martin Spamer Feb 19 '17 at 12:17
  • What should I do, I can't download the repo! – mshwf Feb 19 '17 at 12:18
  • And is there a way to register the host's fingerprint? – mshwf Feb 19 '17 at 12:21
  • As the warning message says, select yes and try again. – Martin Spamer Feb 19 '17 at 14:18
  • 1
    This, incidentally, is a PuTTY issue. PuTTY is not part *of* Git, it's just included with some Windows versions of Git because Git needs the operating system to provide "ssh", the "secure shell", and PuTTY can do that. But PuTTY has its own setup. I don't use Windows (and MacOS, Linux, BSD, etc, all have ssh built-in) so I do not know any details about this. – torek Feb 19 '17 at 18:12
  • Again, you don't need putty here, unless you want to add a passphrase to your private key. Was my ssh-keygen suggestion below helpful? Don't forget to read https://stackoverflow.com/help/accepted-answer: I see you have a lot of questions without any answer being accepted. – VonC Jul 29 '17 at 05:36

4 Answers4

8

Open the command prompt or Git bash and run the following command, where the bracketed term is the username and SSH path of your BitBucket repository:

plink [git@bitbucket.org:company/repo-name.git]

If "plink" is an unrecognized command, make sure the following entries exist in your PATH environment variable and add any that are missing:

  • C:\Program Files (x86)\Git\bin
  • C:\Program Files (x86)\Git\cmd
  • C:\Program Files (x86)\GitExtensions
  • C:\Program Files (x86)\GitExtensions\PuTTY

These are accurate as of GitExtensions version 2.50.01. If Putty is installed elsewhere, add that folder path to the PATH variable. Restart GitExtensions after updating environment variables.

enter image description here

enter image description here

enter image description here

Antony
  • 1,451
  • 1
  • 12
  • 25
  • Thanks Antony, but I really forget that problem, event I'm no longer using Git (currently using TFS), I remember I solved this problem by re-installing Git extensions and changed the configuration. – mshwf Jul 29 '17 at 06:03
1

First, make sure that <git>/usr/bin is added to your PATH (in addition of <git>/bin, with <git> being the PATH where you installed Git)
And use the latest Git for Windows.

Second, don't use putty. As explained in BitBucket (for bitbucket.com, but that applies to a BitBucket server too), all you need is ssh-keygen.

ssh-keygen -t rsa -C "key for BitBucket access" -q -P ""

That will create an id_rsa and id_rsa.pub in your $HOME/.ssh (with $HOME, on Windows, being set by default by Git cmd or Git bash to your %USERPROFILE%: C:\Users\myLogin)

Copy the content of id_rsa.pub (the public key) to your profile in your BitBucket server.

Then try a ssh -T git@yourBitBucketServer: if it asks you to register the server, answer 'y' (yes): your $HOME/.ssh/known_hosts will be updated.
Try again an ssh -T git@yourBitBucketServer and it should work without any more prompt.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @RezaRahmati Make sure to use a simplified PATH as in https://stackoverflow.com/a/49248983/6309: you will then use the right ssh-keygen command, which does support rsa (in `git\latest\usr\bin\ssh-keygen.exe`). (As opposed to the one in `C:\Program Files\OpenSSH\`, described in https://github.com/PowerShell/Win32-OpenSSH/issues/1001#issuecomment-362929297) – VonC Mar 18 '18 at 10:12
0

for me changing from putty to openssh fixed this issue in git extension,

enter image description here

0

If your Putty has the issue, then you can bypass it by substitute plink.exe in the GitExtensions config.

Just add plink-agent.bat into putty installation directory:

@echo off

setlocal

echo.ssh agent command line: %*>&2

start "" /WAIT /B "%~dp0plink.exe" -agent %*

And use plink-agent.bat in the config (Git Extensions -> SSH):

[x] PuTTY

Configure PuTTY

Path to plink: <path-to-putty>\plink-agent.bat

Then add the user name into the url: ssh://username@domain/path

This will avoid interaction with the user. Otherwise it will request the login as input.

If it still requests the input, then you can temporary replace the plink-agent.bat into something like:

@echo off

setlocal

echo.ssh agent command line: %*>&2

type con | "%~dp0plink.exe" -agent %*

Then input into the console, revert back to first variant and run again.

Known Issues:

1.

plink: unknown option "-o"

GitExtensions switched (manually or automatically) to use Other ssh client setting instead of PuTTY.

Currently the GitExtensions checks the extension of the plink executable on settings dialog apply and in case of a batch file does switch to Other ssh client. In that case it will use different command line. You must switch it back to the PuTTY option to use Putty command line.

To do that you must at first switch back to PuTTY option by editing the Path to plink to <path-to-putty>\plink.exe, apply settings dialog and close all instances of GitExtensions.

Only after that you can open the settings file directly in the editor:

c:\Users\User\AppData\Roaming\GitExtensions\GitExtensions\GitExtensions.settings

Find to edit these lines:

    <key>
      <string>plink</string>
    </key>
    <value>
      <string>path-to-putty\plink.exe</string>
    </value>

And replace to:

    <key>
      <string>plink</string>
    </key>
    <value>
      <string>path-to-putty\plink-agent.bat</string>
    </value>

Now it must use the script with the Putty command line.

Beware of Settings dialog. If you open and apply it again (press OK or Apply button), then it may reset the option back to Other ssh client and you will have to repeat the steps above again.

Additionally, you can you use another way which is a bit shorter:

Open settings dialog and edit the Other ssh client option to path-to-putty\plink.exe and apply the setting. If then reopen the dialog (to lookup the option and do not apply the dialog), then it will use PuTTY option with the previous value in the Path to plink field.

2.

fatal: protocol error: bad line length character: logi
FATAL ERROR: Error reading from console: Error 109: ����� ��� ������.

plink trying to request a user name:

login as:

You must add the user name into the url: ssh://username@domain/path

3.

fatal: protocol error: bad line length character: | Pa

plink trying to request a password:

-| Password:

You must run the Putty authentication agent (Pageant) and add the ssh key.

4.

GitExtensions hangs on Pull/Push and Ok button is not enabled.

You must use first variant of plink-agent.bat and remove type con | ... prefix from the plink command.

Andry
  • 2,273
  • 29
  • 28