-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fall back to ssh_options[:user] if host.user.nil? #66
Conversation
Hmm.. I just realized that this does not address the scenario where the user is specified in the global SSH options (as opposed to host-specific), like this: set :ssh_options, auth_methods: %w(publickey), user: fetch(:application) So perhaps this PR is a dud. |
Yes, I am using the global ssh_options, because we always use the same username as the apps name across all servers. |
Actually, maybe this does work after all! It looks like SSHKit merges the global options and the host-specific ones and sets the result on the See: https://github.com/capistrano/sshkit/blob/v1.7.1/lib/sshkit/backends/netssh.rb#L186 host.ssh_options = Netssh.config.ssh_options.merge(host.ssh_options || {}) @felixbuenemann Can you test using this branch and see if it works for your scenario? |
I tried with: gem 'airbrussh', require: false, git: 'https://github.com/mattbrictson/airbrussh', ref: '1d662dc8f9ce487d332c0bf0b899095da03d7d9d' But I'm still seeing The strange thing, reading through your changelog I would have expected to see |
Hmm, or bundler is playing tricks on me, let me verify it's actually using the proper code. |
Yepp, bundler did fool me, or to be precise rubygems-bundler, which doesn't seem to pick up git checkouts. After using |
@mattbrictson Thanks for the quick fix and this great gem! |
1d662dc
to
0944629
Compare
Up until now Airbrussh has displayed the username using `host.name`. However, this may be `nil` in favor of using `ssh_options[:user]`. Use the SSH options in this case. If for some reason no user is specified with either method, then omit the `@` symbol and just print the hostname instead of `@hostname`. Addresses #65.
Fall back to ssh_options[:user] if host.user.nil?
This accounts for changes in sshkit's local username lookup introduced by capistrano/sshkit#293 and also accounts for the conditional formatting changes introduced by mattbrictson#66. The latter did not previously cause failed tests, because the username was stubbed in the tests, causing the relevant code to not be exercised. Now the username is looked up through sshkit, which results in an empty username on sshkit < 1.7.0, so the no-username display is triggered.
This accounts for changes in sshkit's local username lookup introduced by capistrano/sshkit#293 and also accounts for the conditional formatting changes introduced by mattbrictson#66. The latter did not previously cause failed tests, because the username was stubbed in the tests, causing the relevant code to not be exercised. Now the username is looked up through sshkit, which results in an empty username on sshkit < 1.7.0, so the no-username display is triggered. Unfortunately we need to keep the Etc stub for now to avoid crashing on Windows with sshkit 1.7.0 and 1.7.1.
Up until now Airbrussh has displayed the username using
host.name
. However, this may benil
in favor of usingssh_options[:user]
. Use the SSH options in this case.If for some reason no user is specified with either method, then omit the
@
symbol and just print the hostname instead of@hostname
.Addresses #65.
@felixbuenemann does this look good to you?
/cc @robd