xpipe-io / xpipe

Your entire server infrastructure at your fingertips
https://xpipe.io
Apache License 2.0
3.38k stars 88 forks source link

[Feature Request] Import from PuTTY/KiTTY/etc #342

Open valdearg opened 1 month ago

valdearg commented 1 month ago

Wondering if it might be possible to support importing from PuTTY/KiTTY (KiTTY being a fork of PuTTY).

The settings are stored within the registry at the below locations:

KiTTY: HKEY_CURRENT_USER\Software\9bis.com\KiTTY\Sessions

PuTTY: HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions

This looks like the following in the regedit:

image

Fields of interest may be the:

HostName - connection hostname UserName - username to pass to the SSH session. Protocol - with PuTTY supporting multiple protocols, this can be ssh, telnet, serial, etc. Autocommand - this is a command which is sent to the SSH session once logged in.

The session name would come from the registry key name, it seems to use HTML encoding so %20 as spaces etc.

crschnick commented 1 month ago

Hmm, there is still some information missing like authentication methods such as key files. Such an import functionality would only result in incomplete connections.

Do these tools support exporting to a SSH config file?

valdearg commented 1 month ago

Thanks for taking a look! There's a couple of options stored in the registry key regarding authentication:

Password: this seems to be an encrypted value PublicKeyFile: this is the file path to a putty version of the public key, this comes with an extension .ppk

There is then a key for AgentFwd which means "Allow agent forwarding". PuTTY has a version of the SSH agent where the keys can be loaded into, then used globally.

Looks like there's one project here: https://github.com/abdrakhmanov/PuTTY-to-OpenSSH-Converter might be an option.

crschnick commented 1 month ago

Yeah the password can probably not be decrypted. The key files are in a putty-specific format and there are no command-line tools from putty available to convert that into a normal .pem key on Windows. (I guess that's vendor lock in for you) XPipe already support the putty agent (pageant).

valdearg commented 1 month ago

Yeah, they're generated by the PuTTYgen application which is doesn't look like has much of a command line interface (and can be exported out as standard openssh versions), apparently that's by design for the randomness factor in Windows. It looks like the Linux version of this does have the command line options, but probably not too relevant here I suppose.

crschnick commented 1 month ago

Yeah without being able to convert keys I think this is going to be difficult

valdearg commented 1 month ago

I wonder if making a little popup warning might be an option, something like "Please note: passwords and SSH key configs from PuTTY are not imported, these should be updated manually".

Then importing the configs themselves.

crschnick commented 1 month ago

But then you still have to go through every single key in putty and export it manually and then add it in XPipe.

valdearg commented 1 month ago

Good point there, if someone has lots it would be a pain.

Another possibility might be adding in support for the plink application, it can load sessions with the -load option and it can also take the key using -i options.

crschnick commented 1 month ago

In theory it could just run plink -load <name>, yes. But that would not really be an import, more like another integration for a tool.