Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'root': 0.04; 'cc:addr :python-list': 0.09; 'password)': 0.09; 'python': 0.10; '12:57': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'googled': 0.16; 'subject:server': 0.16; 'sudo': 0.16; 'wrote:': 0.16; 'basically': 0.18; 'python?': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'latter': 0.22; 'this:': 0.23; '(this': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'this.': 0.28; 'credentials': 0.29; 'directly,': 0.29; 'invoke': 0.29; 'option': 0.31; "can't": 0.32; 'tue,': 0.34; 'received:google.com': 0.35; 'possible,': 0.35; 'question,': 0.35; 'something': 0.35; 'asking': 0.35; "isn't": 0.35; 'remote': 0.35; 'but': 0.36; 'there': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'doing': 0.38; "won't": 0.38; 'some': 0.40; 'ever': 0.60; 'your': 0.60; "you'll": 0.61; 'entire': 0.61; 'provide': 0.61; 'different': 0.63; 'management': 0.64; 'user,': 0.67; 'chrisa': 0.84; 'subject:commands': 0.84; 'triggering': 0.84; 'ultimately,': 0.84; 'to:none': 0.91; '(running': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=tuCZWxZYMy/a7RA6pOdoB0wFfpeOML43wvq3zKiONeo=; b=w0XEO6i+iGPBi8Qm13X4MJ8eC49vLAxU1sctGSjCHkgc/2/srrottX79t1oz555EFS AI0xbyn34Rci/tgp0SGP72FE8nNhMhgaPrWoQ1w94S5ilawQLAkwdN7vUFYW/KKULnKO a2tZsMKcxD/DG9tfcJwIN6v4ZErNv5OPO4nj6TslPgzvL8jshyAFCRlX9NPMcOHFtbBO anvAIxCZfjWrbJkTEzJl+o5H+z7kJ5xd1CsfROLRPvKGYi7DDApPD8y217D9FuCyo6up UFeLyGBTzuaICSI2U3T2O7oeqGdMYPBE9WfDLrQFnDwBImsJ5xGv5C8aAqM+9Kjwk4Lt bzcQ== MIME-Version: 1.0 X-Received: by 10.50.136.134 with SMTP id qa6mr19288487igb.13.1439867205827; Mon, 17 Aug 2015 20:06:45 -0700 (PDT) In-Reply-To: References: Date: Tue, 18 Aug 2015 13:06:45 +1000 Subject: Re: execute commands as su on remote server From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439867208 news.xs4all.nl 16527 [2001:888:2000:d::a6]:43695 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95455 On Tue, Aug 18, 2015 at 12:57 PM, wrote: > I need to execute commands after doing su to other user on remote server(not sudo which doesn't require password) how i can achieve this using python? > I googled and came to know that its not possible, so just for confirmation asking again, is it possible ? Ultimately, this isn't a Python question, it's a systems administration one. You want a way to execute commands as a specific user, triggering them remotely. There are basically two ways you can do this: either you provide some form of credentials (this is what sudo does), or you elevate the entire management process. The latter option is far FAR easier (running it as root if you might need to go to any different user, or as that specific user if you'll only ever use one), but then you have to ensure, in some way, that your Python program can't be compromised. Python has nothing to do with any of this. If you want to manage elevation using sudo, Python can invoke sudo in a subprocess. If you want to elevate the Python process and then simply invoke something directly, Python won't even be aware of it. ChrisA