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

Allow custom user and port for builder host #620

Merged
merged 2 commits into from
May 21, 2024

Conversation

mlitwiniuk
Copy link
Contributor

When ssh options are set, they overwrite custom username and password passed via ssh builder uri. Passing part of uri for sshkit is fine, as it then properly extracts username and password and forwards it as host.ssh_options (in which case it's no longer empty)

@@ -115,7 +115,7 @@ def connect_to_remote_host(remote_host)
remote_uri = URI.parse(remote_host)
if remote_uri.scheme == "ssh"
options = { user: remote_uri.user, port: remote_uri.port }.compact
on(remote_uri.host, options) do
on(remote_host.gsub('ssh://', ''), options) do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could do:

host = SSHKit::Host.new(
  hostname: remote_uri.host,
  ssh_options: { user: remote_uri.user, port: remote_uri.port }
)
on(host) do
  execute "true"
end

which would avoid needing to alter the options in sshkit_with_ext.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I've updated PR accordingly

When ssh options are set, they overwrite username and password passed as ssh builder uri. Passing part of uri for ssh-kit is fine, as it then properly extracts username and password and forwards it as host.ssh_options (in which case it's no longer empty)
@mlitwiniuk mlitwiniuk force-pushed the allow_custom_ports_for_ssh branch from 79bf674 to 2f91236 Compare April 17, 2024 15:50
lib/kamal/sshkit_with_ext.rb Outdated Show resolved Hide resolved
@mlitwiniuk
Copy link
Contributor Author

Yep, you're right. Closing

@mlitwiniuk mlitwiniuk closed this May 4, 2024
@djmb
Copy link
Collaborator

djmb commented May 7, 2024

@mlitwiniuk - I was just referring to this line when I said we don't need it anymore. I think the rest of the PR is still valid!

host.ssh_options = (host.ssh_options || {}).merge({ port: host.port, user: host.user }.compact)

@djmb
Copy link
Collaborator

djmb commented May 21, 2024

Going to re-open as I think we want this change!

@djmb djmb reopened this May 21, 2024
@djmb djmb merged commit a83df9e into basecamp:main May 21, 2024
8 checks passed
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.

2 participants