From prasanna.mulgaonkar at gmail.com Thu May 21 02:05:22 2015 From: prasanna.mulgaonkar at gmail.com (Prasanna Mulgaonkar) Date: Wed, 20 May 2015 17:05:22 -0700 Subject: [execnet-dev] Question about ssh with sudo over execnet Message-ID: <555D2142.4040208@gmail.com> 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.