Skip to content

as user not working???? #361

Open
Open

Description

@juanbrein
#!/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

Activity

  1. mattbrictson commented on Jul 19, 2016

    @mattbrictson
    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
  2. juanbrein commented on Jul 19, 2016

    @juanbrein
    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!

  3. mattbrictson commented on Jul 19, 2016

    @mattbrictson
    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!

  4. juanbrein commented on Jul 19, 2016

    @juanbrein
    Author

    Sure thing!

    On Tue, Jul 19, 2016 at 4:33 PM, Matt Brictson notifications@github.com
    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
    .

  5. leehambley commented on Aug 9, 2016

    @leehambley
    Member

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

  6. juanbrein commented on Aug 10, 2016

    @juanbrein
    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 notifications@github.com
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions