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

SSH: allow setting config: false to ignore local user ~/.ssh/config #908

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

jeremy
Copy link
Member

@jeremy jeremy commented Aug 13, 2024

Documents the existing config option so it can be set via Kamal config. Allows setting config: false to ignore users' ~/.ssh/config.

@jeremy jeremy requested a review from djmb August 13, 2024 20:08
@igor-alexandrov
Copy link
Contributor

@jeremy are you sure that it exists? I cannot find it, to be honest.

@jeremy
Copy link
Member Author

jeremy commented Sep 30, 2024

You mean the sshkit config option, or ?

@jeremy
Copy link
Member Author

jeremy commented Oct 2, 2024

It eventually lands in Net::SSH.start which passes it to Net::SSH.configuration_for to determine which config files to parse.

Can verify by passing config: /some/other/path.conf and verifying the config is parsed or by enabling/disabling and verifying that default config is/isn't parsed (net-ssh defaults to parsing all of %w[ ~/.ssh/config /etc/ssh_config /etc/ssh/ssh_config ]).

@igor-alexandrov
Copy link
Contributor

@jeremy thanks for the explanation.

@djmb djmb merged commit c10b3fb into main Oct 2, 2024
9 checks passed
@djmb djmb deleted the ignorable-ssh-config branch October 2, 2024 07:28
@Burgestrand
Copy link

Burgestrand commented Oct 17, 2024

I saw this change on the documentation site, but anything else than a boolean isn't accepted.

Specifically this:

Set to [...], or to a file path (or array of paths) to load specific configuration. [...]

ssh:
  config: "config/ssh_config"
❯ kamal config
  ERROR (Kamal::ConfigurationError): ssh/config: should be a boolean

I tested this on both 2.2.2 and 74a06b0.

Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 17, 2024
This gets passed through to SSHKit options. See basecamp#908

Documentation mentions a string or array of strings are allowed, but they are not because:
* Validator example supplies a boolean, so only true/false are enabled.
* `Kamal::Configuration::Ssh#options` doesn't expose `config`, used in lib/kamal/commander.rb:167
@Burgestrand
Copy link

I made a PR #1129 that seems to make this config option do something.

Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 17, 2024
…rings

This is accepted by Net::SSH, research done by @jeremy in basecamp#908 (comment)

This is already documented as working correctly in https://github.com/basecamp/kamal/blob/74a06b0ccda616c86ebe1729d0795f39bcac9f00/lib/kamal/configuration/docs/ssh.yml#L65-L70

However, before this change only booleans were allowed because of the example configuration file.
@jeremy
Copy link
Member Author

jeremy commented Oct 17, 2024

@Burgestrand note this applies to sshkit config, not ssh. Definitely confusing that it doesn't apply elsewhere - probably should have made this an sshkit-specific config and plumbed it through.

@Burgestrand
Copy link

Burgestrand commented Oct 17, 2024

@Burgestrand note this applies to sshkit config, not ssh. Definitely confusing that it doesn't apply elsewhere - probably should have made this an sshkit-specific config and plumbed it through.

@jeremy I don't understand, but I'd like to.

This change was made to lib/kamal/configuration/docs/ssh.yml, which is specifically ssh.

sshkit has its own configuration file in lib/kamal/configuration/docs/sshkit.yml, which doesn't mention anything about this option.

Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 17, 2024
Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 17, 2024
…rings

This is accepted by Net::SSH, research done by @jeremy in basecamp#908 (comment)

This is already documented as working correctly in https://github.com/basecamp/kamal/blob/74a06b0ccda616c86ebe1729d0795f39bcac9f00/lib/kamal/configuration/docs/ssh.yml#L65-L70

However, before this change only booleans were allowed because of the example configuration file.
@jeremy
Copy link
Member Author

jeremy commented Oct 17, 2024

Yep, it's confusing for sure.

SSHKit is configured with config.ssh.options here:

sshkit.ssh_options = config.ssh.options

From there can trace along with #908 (comment)

@jeremy
Copy link
Member Author

jeremy commented Oct 17, 2024

Hmm, indeed! That is the limited/curated set of options. I'll take a closer look at how I was getting the raw config through to SSHKit in my testing.

Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 28, 2024
Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 28, 2024
This is accepted by Net::SSH, research done by @jeremy in basecamp#908 (comment)

This is already documented as working correctly in https://github.com/basecamp/kamal/blob/74a06b0ccda616c86ebe1729d0795f39bcac9f00/lib/kamal/configuration/docs/ssh.yml#L65-L70

However, before this change only booleans were allowed because of the example configuration file.
Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 28, 2024
Burgestrand added a commit to varvet/kamal that referenced this pull request Oct 28, 2024
This is accepted by Net::SSH, research done by @jeremy in basecamp#908 (comment)

This is already documented as working correctly in https://github.com/basecamp/kamal/blob/74a06b0ccda616c86ebe1729d0795f39bcac9f00/lib/kamal/configuration/docs/ssh.yml#L65-L70

However, before this change only booleans were allowed because of the example configuration file.
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.

4 participants