sourcegit icon indicating copy to clipboard operation
sourcegit copied to clipboard

[Feature] (for Windows) Add PuTTY / Plink support as an optional method for SSH agent

Open LiarOnce opened this issue 1 year ago • 5 comments

OpenSSH's ssh-agent may have difficult to troubleshoot functional issues in Windows, and PuTTY can be used as an alternative solution for SSH agents.

LiarOnce avatar Jul 05 '24 13:07 LiarOnce

I have not used PuTTY before, can you explain the differences between it and OpenSSH in use?

love-linger avatar Jul 08 '24 07:07 love-linger

On Windows, PuTTY uses Pageant as the key manager and Plink for connectivity. Instead of using system services like OpenSSH, you can just run Pageant in the background.

All components of PuTTY are portable apps.

image (When using PuTTY as an SSH client in SourceTree)

LiarOnce avatar Jul 08 '24 07:07 LiarOnce

I'm using the following command to specify the private key for a remote:

git -c core.sshCommand="ssh -i '${sshKey}' fetch/pull/push"

What is its equivalent in PuTTY?

Another question, when enable commit GPG signing with SSH method, what do I need to be aware of as opposed to OpenSSH?

image

love-linger avatar Jul 08 '24 09:07 love-linger

I'm not sure how to use Plink for individual repositories, but generally it's used in the form of a global setting:

git config --global core.sshCommand 'plink -ssh'

And it uses this command to use the private key:

plink -ssh -i <putty_key_file>.ppk

The .ppk file here is the PuTTY Private Key format, and it can also be exported as a private key in OpenSSH format.

Regarding GPG, there is no need to pay attention to anything because neither PuTTY nor OpenSSH affects the GPG signing.

LiarOnce avatar Jul 08 '24 12:07 LiarOnce

I'm not sure how to use Plink for individual repositories, but generally it's used in the form of a global setting:

git config --global core.sshCommand 'plink -ssh'

And it uses this command to use the private key:

plink -ssh -i <putty_key_file>.ppk

The .ppk file here is the PuTTY Private Key format, and it can also be exported as a private key in OpenSSH format.

Regarding GPG, there is no need to pay attention to anything because neither PuTTY nor OpenSSH affects the GPG signing.

Thanks very much. Let me think about how to achieve this feature later

love-linger avatar Jul 08 '24 12:07 love-linger

This is just to note that all my repositories are cloned via SSH, with keys being kept in a KeePass database, not as files on a disk drive. KeePassXC is managing keys and feeds them to Pageant, which is the SSH agent. Since SourceGit can pull/push commits without issues, I would assume that the requested functionality is already in place. Does this not work for others?

Edit: Confirmed by removing all keys from Pageant. Fetch displays an error. After unlocking the database, KeePassXC feeds the keys to Pageant and fetch works again.

alensiljak avatar Apr 21 '25 16:04 alensiljak