[execnet-dev] Question about ssh with sudo over execnet
holger krekel
holger at merlinux.eu
Wed Jun 3 17:50:24 CEST 2015
Hi Prasanna,
i guess it is what is expected, yes. It's equivalent to
not using execnet and doing "ssh HOST ; sudo " and then asking
for os.getuid() which returns 0.
best,
holger
On Wed, May 20, 2015 at 17:05 -0700, Prasanna Mulgaonkar wrote:
> Hi Ronny:
>
> Noticed something today that no amount of googling seems to help
> find an answer to--
>
> If I open an ssh connection via execnet, and pass run the link with
> sudo, it appears that the python interpreter at the remote end
> operates with the userid and context of root, not the userid that is
> used to log in. Is this expected behavior? Note that the userid used
> to login is in the sudoers file with all privileges and NOPASS.
>
> Here are two examples. In both cases, the string cmd is:
>
> ```
> >>> cmd = """
> ... import os, pwd
> ... channel.send(pwd.getpwuid(os.getuid()).pw_name)
> ... """
> ```
> which basically returns the userid of the user logged in.
>
> First we run it with sudo:
> ```
> >>> gw = execnet.makegateway("ssh=raxak at 104.b.c.d sudo")
> >>> ch = gw.remote_exec(cmd)
> >>> ch.receive()
> 'root'
> ```
> Note that the output is 'root' despite the fact we logged in with
> raxak as the userid (raxak at 104...)
>
> Next we run the same thing without the sudo:
> ```
> >>> gw = execnet.makegateway("ssh=raxak at 104.b.c.d")
> >>> ch = gw.remote_exec(cmd)
> >>> ch.receive()
> 'raxak'
> >>>
> ```
> This correctly returns the userid as 'raxak'
>
> Just wanted to clarify if this is indeed the expected behavior or am
> I misinterpreting the semantics of what should happen.
>
> _______________________________________________
> execnet-dev mailing list
> execnet-dev at python.org
> https://mail.python.org/mailman/listinfo/execnet-dev
>
--
about me: http://holgerkrekel.net/about-me/
contracting: http://merlinux.eu
More information about the execnet-dev
mailing list