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

Remote user missing if set through ssh_options #65

Closed
felixbuenemann opened this issue Oct 30, 2015 · 10 comments
Closed

Remote user missing if set through ssh_options #65

felixbuenemann opened this issue Oct 30, 2015 · 10 comments
Milestone

Comments

@felixbuenemann
Copy link
Contributor

Currently the remote user in the formatter is empty, if it's set in the ssh_options as opposed to in the server config:

set :application, 'foo'
set :server, 'bar.com'
set :ssh_options, auth_methods: %w(publickey), user: fetch(:application)

server fetch(:server), roles: %w(web app db)

This will display @bar.com instead foo@bar.com for the remote user.

@felixbuenemann
Copy link
Contributor Author

I guess the logic would have to be:

  • Check if the host has a user
  • Check if the ssh_options define a user
  • Fallback to local_user (or whatever is used currently to determine the local user)

@mattbrictson
Copy link
Owner

Thanks for the report!

I don't quick understand what you mean in your third point: "fallback to local_user". Do you mean the equivalent of running whoami on the remote host? I don't know if there is precedence for that in SSHKit.

I can definitely check the ssh_options, though, which should fix this particular issue.

@mattbrictson mattbrictson added this to the 0.7.1 milestone Oct 30, 2015
@felixbuenemann
Copy link
Contributor Author

If no user is specified, sshkit uses either the user from ~/.ssh/config, or if not defined, the current local user, just like ssh example.com would do.

Maybe there's a way to ask sshkit for the actual user it is going to use?

@mattbrictson
Copy link
Owner

The user is determined by net-ssh, which is the underlying library that SSHKit uses. If we had access to the net-ssh Session object, we could probably get the user from it, but the session is not currently exposed by SSHKit's logging facility.

If you think there is a strong case to be made for logging the actual user (as implied by ~/.ssh/config, for example), I suggest you open an SSHKit issue requesting it.

In the meantime, do you think checking for ssh_options[:user] is an acceptable interim fix?

@felixbuenemann
Copy link
Contributor Author

Yes I think it is.

Falling back to the local user, if we're not sure it is actually correct is probably a bad idea…

@mattbrictson mattbrictson modified the milestones: 0.8.0, 0.7.1 Oct 30, 2015
mattbrictson added a commit that referenced this issue Oct 30, 2015
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.
mattbrictson added a commit that referenced this issue Oct 30, 2015
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.
@mattbrictson
Copy link
Owner

This is a bit tricker than I thought (see my failed attempt in PR #66), so I am going to put this on the back-burner for now. Addressing this issue means Airbrussh will have to make some assumptions about how net-ssh works, which makes me a little uncomfortable.

@felixbuenemann if you want to take a stab at a PR I will consider merging it.

@felixbuenemann
Copy link
Contributor Author

Hmm, can't you access the global ssh_options from inside the formatter?

@mattbrictson
Copy link
Owner

@felixbuenemann I think my PR will work after all. Let's move the conversation over to #66.

mattbrictson added a commit that referenced this issue Oct 31, 2015
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.
@mattbrictson mattbrictson added this to the 0.8.0 milestone Oct 31, 2015
@mattbrictson
Copy link
Owner

Fixed by #66.

This will be included in Airbrussh 0.8.0 (release date TBD).

@mattbrictson
Copy link
Owner

Released today in Airbrussh 0.8.0.

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

No branches or pull requests

2 participants