Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78336 > unrolled thread
| Started by | pradeepatjob@gmail.com |
|---|---|
| First post | 2014-09-25 05:28 -0700 |
| Last post | 2014-09-25 22:42 +1000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
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
| From | pradeepatjob@gmail.com |
|---|---|
| Date | 2014-09-25 05:28 -0700 |
| Subject | how to execute the following command using python |
| Message-ID | <27d70eda-ea9d-40d7-a00e-1b9f943df8cd@googlegroups.com> |
Hi group, I am trying to mount a remote network to my Ubuntu system. The remote machine keeps on changes or it is given by the user whoever wants to use my script. so , user enters what to mount. I found following command and it is running successfully when I execute using shell. the command: echo -e 'ubuntumachinepassword/\nremotemachinepasword' | sudo --stdin sshfs root@remoteip:/remotesystem/folder/ /localmountpoint / -o workaround=rename -o password_stdin -o allow_other but when i used this in os.system(abovecommad) i was not successfull. any help on this? thanks & regards Pradeep Kumar
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-09-25 22:42 +1000 |
| Message-ID | <mailman.14356.1411648948.18130.python-list@python.org> |
| In reply to | #78336 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web