> Hi Folkz,
> how can i create a SSH-Connection with python? I have to send some > commands to the remote host and parse their answers.
> greatz Johannes
In article <mailman.2834.1351161105.27098.python-l...@python.org>,
Schneider <j...@globe.de> wrote:
> Hi Folkz,
> how can i create a SSH-Connection with python? I have to send some > commands to the remote host and parse their answers.
> greatz Johannes
At a low level, you want to look at the paramiko library. Built on top of that, and adding hoards of neat functionality, is fabric. One of these is likely to be what you're looking for.
On 2012-10-25, at 3:16 AM, Schneider <j...@globe.de> wrote:
> how can i create a SSH-Connection with python? I have to send some commands to the remote host and parse their answers.
I have yet to use it, but Fabric (http://docs.fabfile.org/en/1.4.3/) should have everything you're looking for. I've heard nothing but good things about it.
On Thu, 25 Oct 2012 12:16:58 +0200, Schneider <j...@globe.de> wrote:
> how can i create a SSH-Connection with python? I have to send some > commands to the remote host and parse their answers.
> greatz Johannes
I've been using Twisted (twistedmatrix.com). It is especially
convenient for the server end. Its organization is "event-driven",
which you may or may not find convenient.
-- To email me, substitute nowhere->spamcop, invalid->net.
On 25 Oct 2012 16:55:46 GMT, Peter Pearson <ppear...@nowhere.invalid> wrote:
> On Thu, 25 Oct 2012 12:16:58 +0200, Schneider <j...@globe.de> wrote:
>> how can i create a SSH-Connection with python? I have to send some >> commands to the remote host and parse their answers.
>> greatz Johannes
> I've been using Twisted (twistedmatrix.com). It is especially
> convenient for the server end. Its organization is "event-driven",
> which you may or may not find convenient.
Oops! The question was about SSH, and I was blathering about SSL.
Sorry.
-- To email me, substitute nowhere->spamcop, invalid->net.
On Oct 25, 2012, at 6:34 AM, Schneider <j...@globe.de> wrote:
> Hi Folkz,
> how can i create a SSH-Connection with python? I have to send some commands to the remote host and parse their answers.
> greatz Johannes
In article <mailman.2915.1351294793.27098.python-l...@python.org>,
Gelonida N <gelon...@gmail.com> wrote:
> Another problem is, that paramiko depends on pycrypto 2.1+
> which doesn't exist as binary release for python 2.7
I'm running paramiko-1.7.6 with python 2.7.3 on my Ubunto Precise box.
I'm reasonably sure all I did was "pip install paramiko".
On the other hand, it may have built it from source during the install.
Generally, I just let pip do it's magic and don't worry about the details. If you're in an environment where you don't have the compiler tool chain, you may be more constrained.
> Is fabric capable of performing scp / sftp
Fabric uses ssh to make connections, and it is capable of copying files.
For all intents and purposes, I'd say that means it is capable of "performing scp / sftp" (both of which are just front-ends to the same basic ssh protocol.
But, keep in mind that fabric depends on paramiko. If you can't get paramiko installed, you probably can't get fabric either.
> In article <mailman.2915.1351294793.27098.python-l...@python.org>,
> Gelonida N <gelon...@gmail.com> wrote:
>> Another problem is, that paramiko depends on pycrypto 2.1+
>> which doesn't exist as binary release for python 2.7
> I'm running paramiko-1.7.6 with python 2.7.3 on my Ubunto Precise box.
> I'm reasonably sure all I did was "pip install paramiko".
Apologies. I failed to mention, that I was talking about Windows not Linux.
I use Python for applications, that should work under Linux and under Windows.
> But, keep in mind that fabric depends on paramiko. If you can't get
> paramiko installed, you probably can't get fabric either.
Thanks, that's good to know, so I don't have to bother looking at farbic (at least not as solution on windows python 2.7 without having to try to recompile pycrypto myself)
On 27Oct2012 14:18, Gelonida N <gelon...@gmail.com> wrote:
| On 10/27/2012 02:21 AM, Roy Smith wrote:
| > In article <mailman.2915.1351294793.27098.python-l...@python.org>,
| > Gelonida N <gelon...@gmail.com> wrote:
| >
| >> Another problem is, that paramiko depends on pycrypto 2.1+
| >> which doesn't exist as binary release for python 2.7
| >
| > I'm running paramiko-1.7.6 with python 2.7.3 on my Ubunto Precise box.
| > I'm reasonably sure all I did was "pip install paramiko".
| | Apologies. I failed to mention, that I was talking about Windows not Linux.
| | I use Python for applications, that should work under Linux and under | Windows.
| | > But, keep in mind that fabric depends on paramiko. If you can't get
| > paramiko installed, you probably can't get fabric either.
| >
| Thanks, that's good to know, so I don't have to bother looking at farbic | (at least not as solution on windows python 2.7 without having to try to | recompile pycrypto myself)
Many years ago we ran an ssh executable on Windows; it was a tiny
standalone kit consisting, IIRC, of the Cygwin libc and ssh. Or you
could just install Cygwin...
That would let you use Python's subprocess module to invoke ssh and
dispatch your command.
-- Cameron Simpson <c...@zip.com.au>
There is a fine line between idiocy and genius. We aim to erase that line.
> On 27Oct2012 14:18, Gelonida N <gelon...@gmail.com> wrote:
> | On 10/27/2012 02:21 AM, Roy Smith wrote:
> | > In article <mailman.2915.1351294793.27098.python-l...@python.org>,
> | > Gelonida N <gelon...@gmail.com> wrote:
> | >
> | >> Another problem is, that paramiko depends on pycrypto 2.1+
> | >> which doesn't exist as binary release for python 2.7
> | >
> | > I'm running paramiko-1.7.6 with python 2.7.3 on my Ubunto Precise box.
> | > I'm reasonably sure all I did was "pip install paramiko".
> |
> | Apologies. I failed to mention, that I was talking about Windows not Linux.
> |
> | I use Python for applications, that should work under Linux and under
> | Windows.
> |
> | > But, keep in mind that fabric depends on paramiko. If you can't get
> | > paramiko installed, you probably can't get fabric either.
> | >
> | Thanks, that's good to know, so I don't have to bother looking at farbic
> | (at least not as solution on windows python 2.7 without having to try to
> | recompile pycrypto myself)
> Many years ago we ran an ssh executable on Windows; it was a tiny
> standalone kit consisting, IIRC, of the Cygwin libc and ssh. Or you
> could just install Cygwin...
> That would let you use Python's subprocess module to invoke ssh and
> dispatch your command.
On all my work PCs cygwin is installed.
However when packaging something with py2exe I'd really prefer to not have to install additional .exe / .dll files just for the ssh client.
This is why I like the idea of Paramiko. which requires the crypto .dll, but that's it.
The only thing I'm concerned about paramiko is, that I don't see any activity on the paramiko site and that one library it depends on is not available is windows binary package for newer versions of python.
For the time being I stick with paramiko as I'm still on py2.6, but I wanted to have some feedback, whether this path can easily be followed in the mid term future or whther I ahd to fall back to a minimalist set
of ssh executables / dlls and a subprocess wrapper.
> On Oct 25, 2012, at 6:34 AM, Schneider <j...@globe.de> wrote:
>> Hi Folkz,
>> how can i create a SSH-Connection with python? I have to send some commands to the remote host and parse their answers.
>> greatz Johannes
> Fabric is the way to go!
In article <mailman.2977.1351455364.27098.python-l...@python.org>,
Gelonida N <gelon...@gmail.com> wrote:
> The sh module looks intersting, but it's not supported for Windows > platforms.
"The X module looks interesting but it's not supported for Windows" is true for many values of X. It's all part of the TCO of using a brain-dead operating system.
On Sun, Oct 28, 2012 at 4:09 PM, Gelonida N <gelon...@gmail.com> wrote:
> The only thing I'm concerned about paramiko is, that I don't see any
> activity on the paramiko site and that one library it depends on is not
> available is windows binary package for newer versions of python.
I don't understand why this is a problem.
\python27\python setup.py install #for pycrypto & paramiko
\python27\python test.py # for paramiko
Works for me. Of course, you need Visual C++ 2008, but the free
express edition is sufficient, and you should have that anyway if
you're doing Windows development. If that's too hard for you, try
http://www.serenethinking.com/bitlift/download.html [not my site, no guarantees]
> On Sun, Oct 28, 2012 at 4:09 PM, Gelonida N <gelon...@gmail.com> wrote:
>> The only thing I'm concerned about paramiko is, that I don't see any
>> activity on the paramiko site and that one library it depends on is not
>> available is windows binary package for newer versions of python.
> I don't understand why this is a problem.
> \python27\python setup.py install #for pycrypto & paramiko
> \python27\python test.py # for paramiko
> Works for me. Of course, you need Visual C++ 2008, but the free
> express edition is sufficient, and you should have that anyway if
> you're doing Windows development. If that's too hard for you, try
> http://www.serenethinking.com/bitlift/download.html > [not my site, no guarantees]
It's not a problem. It's an inconvenience.
We're having multiple PCs. Many of the PC owners don't want to write any C-code and don't want to be bothered with registering at Microsoft just to install a module and using a library.
Normally my preferred approach is, that somebody wanting to use any library, that I wrote) can install all dependencies by:
- Installing Python
- installing easy_install (and pip)
and be able to install all the rest with easy_install
Using a library, that forces users to have to install MS-VC or mingw or to install binaries from non-pypy sites is something I try to avoid.
My next preferred approach would be to bundle such dependencies by myself, but this would involve to check all the legal stuff of each library to see whether this is possible or not, etc . . .
Apart from that I consider the existence of Windows binary packages as
kind of an indicator of the health/popularity of a package and whether it has been used sufficiently under Windows to be considered working well under Windows.
> In article <mailman.2977.1351455364.27098.python-l...@python.org>,
> Gelonida N <gelon...@gmail.com> wrote:
>> The sh module looks intersting, but it's not supported for Windows
>> platforms.
> "The X module looks interesting but it's not supported for Windows" is
> true for many values of X. It's all part of the TCO of using a
> brain-dead operating system.
If I write server side code, then I choose my server and my OS, so I won't encounter Windows
Unfortunately most the customers won't let me choose their client hardware / client OS.
Thus I decide to write my applications cross platform whenever possible and try to choose libraries accordingly.
> On 10/29/2012 02:10 PM, Roy Smith wrote:
> > In article <mailman.2977.1351455364.27098.python-l...@python.org>,
> > Gelonida N <gelon...@gmail.com> wrote:
> >> The sh module looks intersting, but it's not supported for Windows
> >> platforms.
> > "The X module looks interesting but it's not supported for Windows" is
> > true for many values of X. It's all part of the TCO of using a
> > brain-dead operating system.
> If I write server side code, then I choose my server and my OS, so I > won't encounter Windows
> Unfortunately most the customers won't let me choose their client > hardware / client OS.
> Thus I decide to write my applications cross platform whenever possible > and try to choose libraries accordingly.
The other alternative is to chose your customers better :-)