Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for putty/plink ssh.variant (Windows-specific) #3924

Open
jmaerki opened this issue May 31, 2024 · 6 comments
Open
Labels
auth* Issues with authentication and authorisation, usually with forges enhancement An improvement to an existing feature os:windows The Windows platform

Comments

@jmaerki
Copy link

jmaerki commented May 31, 2024

Apologies in advance for another Windows-specific problem. 🫣

On Windows, putty/plink is quite popular as SSH alternative for Git access. Right now,

"{}{base_ssh_command} -o StrictHostKeyChecking=accept-new -o KbdInteractiveAuthentication=no{}",
seems to indiscriminately insert a "-o" param that's not supported by "plink.exe" or "TortoisePLink.exe" (from TortoiseSVN/TortoiseGit).

I found https://www.kolossi.co.uk/git-plink-unknown-option-o/ that shows the usual fix to get Putty/plink working. In my case, my Windows Git installation has the variant as "putty", not "plink", though:

file:C:/Program Files/Git/etc/gitconfig ssh.variant=putty

This is choosable while running the Git for Windows installer.

Subsequent GB error message:

Git push failed
Your branch cannot be pushed due to an unforeseen problem.
Please check our [documentation](https://docs.gitbutler.com/troubleshooting/fetch-push) on fetching and pushing for ways to resolve the problem.
git command exited with non-zero exit code 128: ["push", "--quiet", "origin", "87f8301baf2e2c1981169e3df0e9815efead053e:refs/heads/feature/rotated_content"] STDOUT: STDERR: plink: unknown option "-o" plink: unknown option "-o" fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Also, please note that before running into the problem with the "-o" parameter. I got the following due to a space in the GIT_SSH env variable:

Git push failed
Your branch cannot be pushed due to an unforeseen problem.
Please check our [documentation](https://docs.gitbutler.com/troubleshooting/fetch-push) on fetching and pushing for ways to resolve the problem.
git command exited with non-zero exit code 128: ["push", "--quiet", "origin", "87f8301baf2e2c1981169e3df0e9815efead053e:refs/heads/feature/rotated_content"] STDOUT: STDERR: C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe -o StrictHostKeyChecking=accept-new -o KbdInteractiveAuthentication=no: C:\Program: No such file or directory fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Moving the plink executable to a path without spaces moved me along but resulted in the issue that prompted this ticket.

In the meantime, I'll try to set up an SSH executable instead of plink.

@jmaerki
Copy link
Author

jmaerki commented May 31, 2024

Work-around for me was the following:

  • I'm using KeePass 2 with KeeAgent plugin.
  • I had to "Enable agent for Windows OpenSSH" in the Plugin options and let it create a Cygwin/MSYS compatible socket file.
  • I set a user-level env variable SSH_AUTH_SOCKET to "C:/Somepath/SSH_AUTH_SOCK/cygwin_ssh.sock" (i.e. the file I configured in the step above. Also note the forward slashes instead of backslashes. Single backslashes get stripped.)
  • In the project-level .git/config file I set:
[core]
  sshCommand = \"C:\\\\Program Files\\\\Git\\\\usr\\\\bin\\\\ssh.exe\"
[ssh]
  variant = ssh

GitButler was now able to fetch from the Git repo. Onto the next GB error message...

@Byron Byron added enhancement An improvement to an existing feature os:windows The Windows platform labels Jun 1, 2024
@Byron
Copy link
Collaborator

Byron commented Jun 1, 2024

Thanks so much for investigating this, that will definitely be helpful when trying to get this fixed!

@Byron Byron added the auth* Issues with authentication and authorisation, usually with forges label Jun 1, 2024
@koppor
Copy link

koppor commented Aug 1, 2024

Same wish here - my environment variable is

GIT_SSH=C:\Program Files\PuTTY\plink.exe

The button "Create PR" is without any feedback. Even not an error message...

@koppor
Copy link

koppor commented Aug 1, 2024

Following https://poshsecurity.com/blog/using-the-openssh-client-included-in-windows-10-1809-as-your-gits-ssh-client, it is more easy:

  1. "Enable agent for Windows OpenSSH" in KeeAgent:
    grafik
  2. Set environment variable GIT_SSH to C:/Windows/System32/OpenSSH/ssh.exe.

I did not have success with following: Configure to use Windows' ssh for this repository:

[core]
    sshcommand = C:/Windows/System32/OpenSSH/ssh.exe

@pupitetris
Copy link

Same wish here - my environment variable is

GIT_SSH=C:\Program Files\PuTTY\plink.exe

The button "Create PR" is without any feedback. Even not an error message...

Same env here. I changed it to "C:\Program Files\PuTTY\plink.exe" meaning, surround it with literal quotes, make the quotes part of the value (see how @jmaerki has his ssh.exe location with quotes).

Now, the -o issue is still a problem. It can be hacked away with a pass-through script that filters out those options, but it's not ideal.

@pupitetris
Copy link

plinkFix.ps1.txt

OK, so I wrote a PowerShell script and I'm using it as a workaround for me. I set GIT_SSH to pwsh -noprofile C:\Users\my-user\plinkFix.ps1 and GIT_SSH_VARIANT to plink. You may want to edit the script and set a hardcoded path to plink.exe, and you can activate the logging if something breaks to see what arguments are being received and how the script is filtering them.

The script has requirement clauses for PowerShell Core version 7, but you may be able to use the Desktop version and call powershell instead of pwsh and it will probably work anyways if you remove the clauses (first 4 lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth* Issues with authentication and authorisation, usually with forges enhancement An improvement to an existing feature os:windows The Windows platform
Projects
None yet
Development

No branches or pull requests

4 participants