It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SourceTree: plink unkown option "-p"

I'm receiving the below error when attempting to do anything with Git over SSH on a non-standard port, and was wondering if anyone could help solve the issue.

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch --prune origin
plink: unknown option "-p"
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Completed with errors, see above.

 

Environment 

Windows 10 Pro 64 bit

Sourcetree 2.5.4 (Windows)

Git 2.16.1 (System)

Git 2.15.1 (Embedded)

plink 0.70.2 (Embedded)

Putty/plink 0.70.0 (System)

TortoiseGit 2.6.0

 

Other Details

  • I believe the correct option to specify a port should be a capital "-P", but I don't understand why SourceTree is using a lowercase one.
  • Git URL format: ssh://user@domain.com:553/path/my-repo
  • Access to the Git repo via SSH is confirmed working with TortoiseGit on the same system

2 answers

I fixed this by going to Options=>General under the SSHClient configuration section, there is a dropdown for SSHClient.

 

Capture.PNG

I chose OpenSSH instead of "Putty / Plink". You may have to install openssh on your machine before you see this option in your dropdown. That fixed it for me.

minnsey Atlassian Team Aug 14, 2018

OpenSSH is picked up from the Git client, it should always be available.

0 votes
minnsey Atlassian Team Apr 16, 2018

Hi

As far as I can see the only time we make use of the -P option is if there is an interaction with the remote that triggers a response indicating the server's host key is not cached or has changed.

We then re-run plink.exe with the -P option if required, but that should be uppercase.

If this is the case you should have been prompted by Sourcetree to accept the new SSH key, did this happen?

You can find out a bit more about what might be happening be enabling DEBUG logging, by changing ERROR to DEBUG in %localappdata%/Sourcetree/app-2.5.4/log4net.config

This will log to %localappdata%/Atlassian/Sourcetree/sourcetree.log you should be able to find any plink.exe calls with associated arguments in there.

I don't recall Sourcetree initially asking to accept the SSH key, but maybe that has something to do with possibly accepting it via TortoiseGit previously?.

I did attempt to completely remove Sourcetree and re-install it to try again. It did not prompt for accepting the SSH Key. If you can provide an idea of where/how to clear out cached keys I can attempt to do that.

On a recent attempt I accidentally misspelled the repo name in the URL (but everything else was correct), Sourcetree did prompt to accept the SSH key. This ultimately failed though because my repo name was incorrect. After correcting the spelling, it functioned as previously with the same output.

I made the log4net config change and did see a lot more output into sourcetree.log, but nothing that stood out or seemed to provide anymore info in relation to the error.

The command that Sourcetree is saying it's attempting to run (above), I attempted to run that manually in both Git Bash and PowerShell and got the exact same error in response

Just updated (System) Git to 2.16.2 (from 2.16.1) and it seems to have fixed the issue for Git when used from PowerShell or Git Bash, but issue remains with Sourcetree regardless of using System or Embedded Git.

Workaround found:

I have just managed to find a workaround for the issue by replacing SourceTree/app-*/tools/plink.exe  with TortoiseGitPlink.exe (renamed to plink.exe). It should be noted that I tried to do the same by using Putty's plink.exe, but this did not work and resulted in the same issue.

This also explains the above where re-installing Git fixed the issue for Git via shell, because Git via shell looks at the GIT_SSH environment variable, which pointed to TortoiseGItPlink.exe when it was detected during re-installation of Git, meaning Git was using TortoiseGitPlink.exe and working.

SourceTree obviously does not use GIT_SSH environment variables, and prefers it's own plink.exe which for whatever reason I am having an issue with.

minnsey Atlassian Team Apr 19, 2018

Thanks for the detailed response. We will add it to our backlog to investigate.

That helped! Thank you sir.

I fixed this by going to Options->General under the SSHClient configuration section, there is a dropdown for SSHClient. I chose OpenSSH instead of Putty / Plink. You may have to install openssh on your machine before you see this option in your dropdown. That fixed it for me.

FYI I seem to recently be having the same issue on another dev system. The suggested workaround above still worked (replacing plink.exe)

I've replaced it with that found in TortoiseGit, which is (plink) version 0.70.0 . The version in SourceTree is 0.70.2

this problem again. Yesterday in an attempt to fix a different issue with the push dialog I updated Git for Windows to 2.26.0 and installed Embeded Git 2.24.1. Now today this issue has shown up again.

For SourceTree 3.3.8 I found that switching between Embedded Git or System Git, SourceTree will use the same SourceTree plink 0.70.2 and pageant 0.70.2. It will succeed in fetching when using Embedded Git but will fail when using System Git.

If I manually run Putty pageant 0.73 instead, SourceTree will succeed/fail in the exact same way when switching between Embedded/System Git.

If I replace SourceTree plink with Putty plink 0.73, Sourcetree will succeed/fail in the exact same way when switching between Embeeded/System Git.

If I replace SourceTree plink with TortoiseGit plink 0.73, SourceTree will succeed in both cases regardless of Embedded/System Git.

So solutions so far seem to be:

  • Use Embedded Git
  • Use OpenSSH, not Putty/Plink, for SSH Client (See Tools > Options > General)
  • Replace SourceTree plink with TortoiseGit plink

I look forward to resolving this issue again next year ;)

this problem again. Yesterday in an attempt to fix a different issue with the push dialog I updated Git for Windows to 2.26.0 and installed Embeded Git 2.24.1. Now today this issue has shown up again.

What I suspect has happened is that by installing Embedded Git, it has replaced SourceTree's embedded plink.exe, which I have previously had issues with.

For SourceTree 3.3.8 I found that switching between Embedded Git or System Git, SourceTree will use the same SourceTree plink 0.70.2 and pageant 0.70.2. It will succeed in fetching when using Embedded Git but will fail when using System Git.

If I manually run Putty pageant 0.73 instead, SourceTree will succeed/fail in the exact same way when switching between Embedded/System Git.

If I replace SourceTree plink with Putty plink 0.73, Sourcetree will succeed/fail in the exact same way when switching between Embeeded/System Git.

If I replace SourceTree plink with TortoiseGit plink 0.73, SourceTree will succeed in both cases regardless of Embedded/System Git.

So solutions so far seem to be:

  • Use Embedded Git
  • Use OpenSSH, not Putty/Plink, for SSH Client (See Tools > Options > General)
  • Replace SourceTree plink with TortoiseGit plink

I look forward to resolving this issue again next year ;)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

4,917 views 0 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you