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

as user not working???? #361

Open
juanbrein opened this issue Jul 19, 2016 · 6 comments
Open

as user not working???? #361

juanbrein opened this issue Jul 19, 2016 · 6 comments

Comments

@juanbrein
Copy link

juanbrein commented Jul 19, 2016

#!/usr/bin/env ruby
require 'sshkit'                               
require 'sshkit/dsl'                           
include SSHKit::DSL                            


on %w{srv16} do |host|
  as 'jbrein' do
    execute 'whoami'                           
  end                                          
end

Triggers:

vagrant@srv16  password::

where:

#!/usr/bin/env ruby
require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL


on %w{srv16} do
  host.user = 'jbrein'
  execute 'whoami'
end

I get:

INFO [d05e2de1] Running /usr/bin/env whoami as jbrein@srv16
INFO [d05e2de1] Finished in 1.172 seconds with exit status 0 (successful).

I hope I'm doing something wrong.. don't know what because I believe I'm following the documentation strictly...

Thanks

@mattbrictson
Copy link
Member

Hi, thanks for the report. I think as works differently than you expect.

Using as, the connection is still established using the default user. In your case, the default user is vagrant (based on $USER, I assume).

It's only after the connection is established that sudo -u [USER] is used to run the command "as" that user.

If you want to change the user that is used for the actual SSH connection, then you should specify that user as part of the host using user@host syntax, like this:

on %w{jbrein@srv16} do
  execute "whoami"
end

@juanbrein
Copy link
Author

I see! I was getting crazy trying to figure out what was going on. I don't see that in the README, can this be considered a bug in the documentation? Is it something that can lead to confusion or it was just me?

Thanks anyway for the clarification!

@mattbrictson
Copy link
Member

Yes, I can imagine that would be confusing. Would you mind suggesting some edits? You can press the edit button (pencil icon) on either the README or the EXAMPLES and it will automatically create a pull request that I can review. Thanks!

@juanbrein
Copy link
Author

Sure thing!

On Tue, Jul 19, 2016 at 4:33 PM, Matt Brictson [email protected]
wrote:

Yes, I can imagine that would be confusing. Would you mind suggesting some
edits? You can press the edit button (pencil icon) on either the README
https://github.com/capistrano/sshkit/blob/master/README.md or the
EXAMPLES https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md
and it will automatically create a pull request that I can review. Thanks!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#361 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACzpvqyPMrsiwkCNc2RSF6wR2vjDRoQfks5qXV6ygaJpZM4JQMmG
.

@leehambley
Copy link
Member

bump @juanbrein - were you able to make some edits to the documentation to clarify this?

@juanbrein
Copy link
Author

Sorry I'm on holidays, but will pick it up when back. Probably on Monday.
Thanks!

On Tue, Aug 9, 2016 at 9:57 AM, Lee Hambley [email protected]
wrote:

bump @juanbrein https://github.com/juanbrein - were you able to make
some edits to the documentation to clarify this?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#361 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACzpvnxx2gSB1nyJ8C-aCbMHm-mnSG8Nks5qeLGMgaJpZM4JQMmG
.

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

3 participants