bgtunnel icon indicating copy to clipboard operation
bgtunnel copied to clipboard

Specify ssh config file and/or known_hosts location?

Open nhansendev opened this issue 2 years ago • 1 comments

I'm trying to relocate the ssh keys to another folder instead of the default on Linux. Currently I can use the identity_file kwarg to specify which private key file to use, but this only works if the known_hosts file is still in its original folder.

I've tried making a config file with both the identity file and known hosts file paths specified, but this does not work as the identity_file:

IdentityFile *path1*
UserKnownHostsFile *path2*

Is there a way to specify the known_hosts location, or a config file?

Edit: Per the ssh manual page specifying the config is an existing option:

-F configfile
            Specifies an alternative per-user configuration file.  If a
            configuration file is given on the command line, the
            system-wide configuration file (/etc/ssh/ssh_config) will
            be ignored.  The default for the per-user configuration
            file is ~/.ssh/config.  If set to “none”, no configuration
            files will be read.

It looks like this could be added very similarly to how identity_file is.

An additional/alternative option is to add -o, which allows (among other things) UserKnownHostsFile to be specified:

-o option
             Can be used to give options in the format used in the
             configuration file.  This is useful for specifying options
             for which there is no separate command-line flag.  For full
             details of the options listed below, and their possible
             values, see ssh_config(5).

nhansendev avatar Jun 29 '23 05:06 nhansendev

Added a pull request to address the issue by adding a config_file option. The config file can contain paths to the identity and known hosts files, so it solves the issue for me.

nhansendev avatar Jun 29 '23 23:06 nhansendev