Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tmate-server-port when using libssh 0.9 #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aebm
Copy link

@aebm aebm commented Feb 19, 2020

  • Since libssh 0.9 doing ssh_connect will call parse_config
    (unless it is deactivated SSH_OPTIONS_PROCESS_CONFIG)
    if ~/.ssh/config hasn't been parsed, overwriting the port option.
    So this will call parse_first before setting the port with
    tmate-server-port as commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b.

    Fixes set -g tmate-server-port "xxxx" doesn't when there is a port defined in ~/.ssh/config #167

    Commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b in libssh

As the configuration parsing is the last thing before doing the
actual connection, it might overwrite previously set options.
If this is not intended, the client application can
ask the configuration files to be parsed before setting some other
options that should not ve overwritten.

* Since libssh 0.9 doing ssh_connect will call parse_config
  (unless it is deactivated SSH_OPTIONS_PROCESS_CONFIG)
  if ~/.ssh/config hasn't been parsed, overwriting the port option.
  So this will call parse_first before setting the port with
  tmate-server-port as commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b.

  Fixes tmate-io#167

  Commit 89a8a6fcf07368c56a98ff8168db77b6814fbe7b in libssh

  As the configuration parsing is the last thing before doing the
  actual connection, it might overwrite previously set options.
  If this is not intended, the client application can
  ask the configuration files to be parsed before setting some other
  options that should not ve overwritten.
@nviennot
Copy link
Member

Thank you for the PR :)

Should the call to ssh_options_parse_config(session, NULL); be placed before all the calls to ssh_options_set() ?

@aebm
Copy link
Author

aebm commented Mar 6, 2020

Hi,

Sorry for the delay. It depends your intend. If you want that libssh don't overwrite connection options after parsing ssh_config, then you will have to call first ssh_options_parse_config(session, NULL) and then ssh_options_set() to overwrite. That is what docs shows.

@ansasaki
Copy link

ansasaki commented Apr 22, 2020

Hello,

As @aebm said, the options set by configuration files are overridden by options set using ssh_options_set(). For this reason, ssh_options_parse_config(session, NULL) should be called before options passed explicitly (e.g. through command line options). The only option required to be set before calling ssh_options_parse_config(session, NULL) is SSH_OPTIONS_HOST.

The idea when it was designed was that the application would like to have the following priority order for the options:

1- Options set explicitly by the user (e.g. through command line)
2- Options set by the user through configuration files
3- Global options, usually set by the system
4- Options set by default by the application

The idea behind overriding the applications defaults with the global configurations is to keep the list of used algorithms up-to-date even when the application code is not frequently updated. And for the local configurations overriding the system-wide configurations is to give the user the option to easily override the system-wide defaults.

To make the application to follow the priority order I mentioned above, the order of calls should be:

  1. Set application defaults using ssh_options_set()
    • Options set here will be overridden by options present in the configuration files
  2. Explicitly call ssh_options_parse_config(session, NULL)
    • This will make libssh to parse the local user configuration and the global configuration (from the system). Once the global configuration is parsed, it will not be parsed again.
  3. Set options passed explicitly by the user with ssh_options_set()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set -g tmate-server-port "xxxx" doesn't when there is a port defined in ~/.ssh/config
3 participants