Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78338

Re: how to execute the following command using python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'root': 0.05; 'permitted': 0.07; 'plenty': 0.07; 'read-only': 0.09; 'skip:/ 10': 0.09; 'subject:command': 0.09; 'subject:using': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'project,': 0.12; 'stored': 0.12; 'suggest': 0.14; 'access).': 0.16; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'implies': 0.16; 'password,': 0.16; 'script,': 0.16; 'ssh': 0.16; 'sudo': 0.16; 'subject:python': 0.16; '(you': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'file,': 0.19; 'thu,': 0.19; 'issue.': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; "shouldn't": 0.24; 'text.': 0.24; 'file.': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'usually': 0.31; '25,': 0.31; 'embedding': 0.31; 'globally': 0.31; 'sep': 0.31; "skip:' 40": 0.31; 'anyone': 0.31; 'file': 0.32; 'run': 0.32; 'text': 0.33; '(including': 0.33; 'subject:the': 0.34; 'info': 0.35; 'knows': 0.35; 'received:google.com': 0.35; 'machine.': 0.36; 'passwords': 0.36; 'done': 0.36; 'doing': 0.36; 'should': 0.36; 'two': 0.37; 'clear': 0.37; 'remote': 0.38; 'pm,': 0.38; 'that,': 0.38; 'itself': 0.39; 'either': 0.39; 'how': 0.40; 'even': 0.60; 'access,': 0.60; 'dangerous': 0.60; "you're": 0.61; 'first': 0.61; "you've": 0.63; 'address': 0.63; 'management': 0.65; 'granted': 0.65; 'skip:r 30': 0.69; 'ranges': 0.74; 'locked': 0.84; 'to:none': 0.92; 'login.': 0.93
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=aDkQBw2zEIX2/yyFNiMNDiSZPXzdvhx7WNALl/pOdNc=; b=biOK06TJgQtX09R/cyqeV497lkyKdkUSxoG9O5UhsMBff92Vu2ESFR9OyvWgoV3QWS n0Fx5wl2j2R66cZoC+VySfp9zEMFDVyHNicYwpp7+hK37ylTc91v7642iu02pvu7rOpn +owEzfwNKP2G8gebl0KPWVOWuyTosuq3yYPRg58eVKnZpbE7zeCnUyzBFMsUdypULZgq EWr+m+wFoag4f3d4G7jDFCphgnKsPMr07JXx4s8ubyaXG7ZjkOfTjC3WmfIk03K/YAJf c008Wn8jt2DIai4YWKWEJt2CVeuKOYuZaGgkGlQ9yLIaWjnMvaG4xEUKQPYiwrj1Yyr5 6onw==
MIME-Version 1.0
X-Received by 10.43.94.7 with SMTP id bw7mr16642153icc.26.1411648939302; Thu, 25 Sep 2014 05:42:19 -0700 (PDT)
In-Reply-To <27d70eda-ea9d-40d7-a00e-1b9f943df8cd@googlegroups.com>
References <27d70eda-ea9d-40d7-a00e-1b9f943df8cd@googlegroups.com>
Date Thu, 25 Sep 2014 22:42:19 +1000
Subject Re: how to execute the following command using python
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14356.1411648948.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411648948 news.xs4all.nl 2869 [2001:888:2000:d::a6]:42964
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78338

Show key headers only | View raw


On Thu, Sep 25, 2014 at 10:28 PM,  <pradeepatjob@gmail.com> wrote:
> echo -e 'ubuntumachinepassword/\nremotemachinepasword' | sudo --stdin sshfs root@remoteip:/remotesystem/folder/  /localmountpoint / -o workaround=rename -o password_stdin -o allow_other
>

This implies that you're embedding two passwords in the script, in
clear text. I suggest not doing this - it's actually easier that way.
All you need to do is permit passwordless access: first to sudo, then
to the remote machine.

Passwordless sudo access can be done either globally or for this one
specific password, via the sudoers file. You can find out how to do
that on the internet; it's not a Python issue. Passwordless SSH
(including sshfs) is usually done with a key pair - look up ssh-keygen
and the authorized_keys file (you put your public key into that file,
and access is granted without a password). Again, plenty of info about
that on the internet.

(Side point: I strongly recommend NOT granting access via the root
login. Even if you know what you're doing, even if you think you've
locked it down to just SFTP, even if you think it's granting read-only
access, I still say mounting root@anything is a dangerous thing to do.
And if you haven't locked it down, and are giving root shell access to
anyone who knows a password that's stored in clear text in a script...
you definitely shouldn't be doing that.)

Once you have that, all you need is to run this:

sudo sshfs root@remoteip:/remotesystem/folder /localmountpoint -o allow_other

and you might not even need "-o allow_other". Everything should just
work by itself - that's what I do with the Yosemite Project, with an
additional feature of automating the authorized_keys management (based
on IP address ranges that are permitted access).

ChrisA

Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

how to execute the following command using python pradeepatjob@gmail.com - 2014-09-25 05:28 -0700
  Re: how to execute the following command using python Chris Angelico <rosuav@gmail.com> - 2014-09-25 22:42 +1000

csiph-web