Re: SSH Connection with Python

2012-10-29 Thread Schneider

thank you guys for the huge list of answers,
In my setting I have to access some routers and firewall from a 
linux-client.


I think I'll try Fabric.


On 26.10.2012 06:20, Rodrick Brown wrote:

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!


--
http://mail.python.org/mailman/listinfo/python-list


--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread Christian
Am Donnerstag, 25. Oktober 2012 12:31:46 UTC+2 schrieb Schneider:
 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

There is a module in chilkat.
http://www.example-code.com/python/ssh_exec.asp
Don't know if it is worth the money, never used it.

Christian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread Roy Smith
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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread David Robinow
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]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread Gelonida N

On 10/29/2012 04:18 PM, David Robinow wrote:

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.









--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread Gelonida N

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.







--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-29 Thread Roy Smith
In article mailman.3048.1351547492.27098.python-l...@python.org,
 Gelonida N gelon...@gmail.com wrote:

 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 :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-28 Thread Gelonida N

On 10/28/2012 02:35 AM, Cameron Simpson wrote:

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.



--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-28 Thread Gelonida N

On 10/26/2012 05:22 AM, Jason Friedman wrote:

how can i create a SSH-Connection with python? I have to send some commands
to the remote host and parse their answers.


Consider also the sh module:
http://amoffat.github.com/sh/tutorials/2-interacting_with_processes.html.




Just a minor comment:  The sh module looks intersting, but it's not 
supported for Windows platforms.


Please note: I'm not the original poster, so perhaps this is no issue 
for him.


--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-27 Thread Gelonida N

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)



--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-27 Thread Cameron Simpson
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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-26 Thread Gelonida N

On 10/25/2012 12:47 PM, Kamlesh Mutha wrote:

You can use paramiko module. Very easy to use.




I also use paramiko for a small script.

However I'm a little hesitant to use paramik for new code.

The web page says: last updated 21-May-2011

and the github url  http://github.com/robey/paramiko/
yields me a 404

However I didn't really find any alternative.
For cross platform scripts  (Linux / windows)
subprocess is not such a good alternative.


Another problem is, that paramiko depends on pycrypto 2.1+
which doesn't exist as binary release for python 2.7


Is fabric capable of performing scp / sftp

Is there any other library as alternative?

--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-26 Thread Roy Smith
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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Laszlo Nagy

On 2012-10-25 12:16, Schneider 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

http://www.lag.net/paramiko/

Another solution would be to use subprocess and/or pexpect


--
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Kamlesh Mutha
You can use paramiko module. Very easy to use.



On Thu, Oct 25, 2012 at 4:04 PM, Laszlo Nagy gand...@shopzeus.com wrote:

 On 2012-10-25 12:16, Schneider 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

 http://www.lag.net/paramiko/

 Another solution would be to use subprocess and/or pexpect


 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list




-- 
Faith waiting in the heart of a seed promises a miracle of life which it
can not prove!
-Ravindranath Tagore
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Roy Smith
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.

http://www.lag.net/paramiko/

https://github.com/fabric/fabric
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Demian Brecht

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.

Demian Brecht
@demianbrecht
http://demianbrecht.github.com




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Peter Pearson
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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python - Oops

2012-10-25 Thread Peter Pearson
On 25 Oct 2012 16:55:46 GMT, Peter Pearson ppearson@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.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Jason Friedman
 how can i create a SSH-Connection with python? I have to send some commands
 to the remote host and parse their answers.

Consider also the sh module:
http://amoffat.github.com/sh/tutorials/2-interacting_with_processes.html.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SSH Connection with Python

2012-10-25 Thread Rodrick Brown
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!

 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list