pahaz / sshtunnel

SSH tunnels to remote server.
MIT License
1.23k stars 184 forks source link

~/.ssh/config Include directive being ignored #280

Open Smylers opened 1 year ago

Smylers commented 1 year ago

When processing the ~/.ssh/config file, sshtunnel appears not to act on the Include directive, to load further config from a different file. This means it uses different SSH config from the ssh command making a connection to the same server.

My set-up is generic SSH config in ~/.ssh/config, which ends with this to include further config:

Include ~/.ssh/local_config

(That's so that the first file can be copied to all computers I use, shared with others, and so on. The second file contains anything to do with specific user accounts or hosts, which varies and may be private.)

I think sshtunnel isn't using the config from the included file, so is trying to connect using the wrong username (and therefore failing). This is with version 0.4.0.

The relevant config is acted on if temporarily pasted into ~/.ssh/config itself; and it also uses it if I specify sshtunnel -c ~/.ssh/local_config — but that then obviously misses out settings from the main ~/.ssh/config file.

To reproduce:

  1. Have somewhere to SSH to which requires a config directive, for instance a username which is different from the local username.
  2. Put that config in its own file, and Include that file from ~/.ssh/config.
  3. Use ssh to connect, and see that it works, taking the config from the included file.
  4. End that connection and use sshtunnel, finding that it fails (and using a -v or 2 to see what it's doing, for instance trying the wrong username).
  5. Move that config into the min ~/.ssh/config and verify that both ssh and sshtunnel now use it.

Please could sshtunnel support Include? Thanks.