veeso / termscp

🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3/SMB
https://termscp.veeso.dev
MIT License
1.61k stars 46 forks source link

[Feature Request] - Support UseKeychain in ssh config file #92

Closed mgray88 closed 2 years ago

mgray88 commented 2 years ago

Description

My SSH keys are themselves passphrase protected, and MacOS stores those passphrases in the Keychain so I don't have to enter them everytime

Description from man ssh_config:

On macOS, specifies whether the system should search for passphrases in the user's keychain when attempting to use a particular key. When the passphrase is provided by the user, this option also specifies whether the passphrase should be stored into the keychain once it has been verified to be correct. The argument must be “yes” or “no”. The default is “no”.

Changes

The following changes to the application are expected

veeso commented 2 years ago

It sounds cool, but I would take another approach, to be honest.

For architectural reasons, I don't think this is possible to be implemented in the ssh client, but this may be a chance to implement something which is still missing and which would make sense. Probably I've never thought about it since I basically never use the CLI argument to connect, but I'm glad that someone uses them.

A better approach here would be to add a new flag to the CLI options (such as -b) which would tell termscp that the hostname is not an address to resolve, but a bookmark name. In this case, you would be able to save the connection parameters along with the password as a bookmark with a name (e.g. foo) and then automatically connect with termscp -b foo.

Since the password argument is used, if necessary, to unlock an encrypted ssh key, this would solve the issue I guess.

mgray88 commented 2 years ago

 The main issue is I haven't been able to use termscp at all because it doesn't seem to cooperate with my environment. Or maybe I just don't fully understand it? Like I mentioned, I can ssh my_host and it connects using the fields from my config file and ssh-agent. All of my IdentityFiles are also password protected, which is where UseKeychain comes into play.

I guess my big question then is, how does termscp use the config file? It doesn't seem to read it for the SSH Keys pane or "bookmarks" which I might have hoped it would add the Hosts. It seems to read it right when I go to connect from the UI, but if UseKeychain is in the file, it errors with: IO error (Could not parse configuration file: unknown field: UseKeychain

From someone who has an well defined ssh environment, termscp seemed like it would be a nice addition to my toolkit. If it's not able to use my already defined environment and requires modifying and redefining everything that makes me sad :(

veeso commented 2 years ago

There's an issue with ssh2-config, which doesn't recognize UseKeychain since it was not listed in the Unix manual (because it's available only on macos). I need to patch this in ssh2-config and then update termscp.

veeso commented 2 years ago

Fixed in 0.8.1 branch, due to ssh2-config updated to 0.1.3

mgray88 commented 2 years ago

Hi @veeso, any chance for a release of 0.8.1?

veeso commented 2 years ago

Hi, unfortunately, I've been really busy recently, so the release of 0.8.1 has been quite delayed. I hope to find the time to work on the last developments in order to release this version.