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

References <27d70eda-ea9d-40d7-a00e-1b9f943df8cd@googlegroups.com>
Date 2014-09-25 22:42 +1000
Subject Re: how to execute the following command using python
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.14356.1411648948.18130.python-list@python.org> (permalink)

Show all headers | 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