Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
SSH Connection with Python
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  22 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Schneider  
View profile  
 More options Oct 25 2012, 6:31 am
Newsgroups: comp.lang.python
From: Schneider <j...@globe.de>
Date: Thu, 25 Oct 2012 12:16:58 +0200
Local: Thurs, Oct 25 2012 6:16 am
Subject: SSH Connection with Python
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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laszlo Nagy  
View profile  
 More options Oct 25 2012, 6:38 am
Newsgroups: comp.lang.python
From: Laszlo Nagy <gand...@shopzeus.com>
Date: Thu, 25 Oct 2012 12:34:37 +0200
Local: Thurs, Oct 25 2012 6:34 am
Subject: Re: SSH Connection with Python
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Oct 25 2012, 8:18 am
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Thu, 25 Oct 2012 08:18:47 -0400
Local: Thurs, Oct 25 2012 8:18 am
Subject: Re: SSH Connection with Python
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Demian Brecht  
View profile  
 More options Oct 25 2012, 9:54 am
Newsgroups: comp.lang.python
From: Demian Brecht <demianbre...@gmail.com>
Date: Thu, 25 Oct 2012 06:54:43 -0700
Local: Thurs, Oct 25 2012 9:54 am
Subject: Re: SSH Connection with Python

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Pearson  
View profile  
 More options Oct 25 2012, 12:55 pm
Newsgroups: comp.lang.python
From: Peter Pearson <ppear...@nowhere.invalid>
Date: 25 Oct 2012 16:55:46 GMT
Local: Thurs, Oct 25 2012 12:55 pm
Subject: Re: SSH Connection with Python

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "SSH Connection with Python - Oops" by Peter Pearson
Peter Pearson  
View profile  
 More options Oct 25 2012, 7:08 pm
Newsgroups: comp.lang.python
From: Peter Pearson <ppear...@nowhere.invalid>
Date: 25 Oct 2012 23:08:27 GMT
Local: Thurs, Oct 25 2012 7:08 pm
Subject: Re: SSH Connection with Python - Oops
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "SSH Connection with Python" by Jason Friedman
Jason Friedman  
View profile  
 More options Oct 25 2012, 11:22 pm
Newsgroups: comp.lang.python
From: Jason Friedman <ja...@powerpull.net>
Date: Thu, 25 Oct 2012 21:22:41 -0600
Local: Thurs, Oct 25 2012 11:22 pm
Subject: Re: SSH Connection with Python

> 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.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrick Brown  
View profile  
 More options Oct 26 2012, 12:20 am
Newsgroups: comp.lang.python
From: Rodrick Brown <rodrick.br...@gmail.com>
Date: Fri, 26 Oct 2012 00:20:13 -0400
Local: Fri, Oct 26 2012 12:20 am
Subject: Re: SSH Connection with Python
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!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 26 2012, 7:39 pm
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Sat, 27 Oct 2012 01:39:36 +0200
Local: Fri, Oct 26 2012 7:39 pm
Subject: Re: SSH Connection with Python
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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Oct 26 2012, 8:21 pm
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Fri, 26 Oct 2012 20:21:48 -0400
Local: Fri, Oct 26 2012 8:21 pm
Subject: Re: SSH Connection with Python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 27 2012, 8:19 am
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Sat, 27 Oct 2012 14:18:11 +0200
Local: Sat, Oct 27 2012 8:18 am
Subject: Re: SSH Connection with Python
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)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cameron Simpson  
View profile  
 More options Oct 27 2012, 8:35 pm
Newsgroups: comp.lang.python
From: Cameron Simpson <c...@zip.com.au>
Date: Sun, 28 Oct 2012 11:35:23 +1100
Local: Sat, Oct 27 2012 8:35 pm
Subject: Re: SSH Connection with Python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 28 2012, 4:09 pm
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Sun, 28 Oct 2012 21:09:18 +0100
Local: Sun, Oct 28 2012 4:09 pm
Subject: Re: SSH Connection with Python
On 10/28/2012 02:35 AM, Cameron Simpson wrote:

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 28 2012, 4:16 pm
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Sun, 28 Oct 2012 21:15:52 +0100
Local: Sun, Oct 28 2012 4:15 pm
Subject: Re: SSH Connection with Python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Schneider  
View profile  
 More options Oct 29 2012, 8:49 am
Newsgroups: comp.lang.python
From: Schneider <j...@globe.de>
Date: Mon, 29 Oct 2012 13:48:28 +0100
Local: Mon, Oct 29 2012 8:48 am
Subject: Re: SSH Connection with Python
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian  
View profile  
 More options Oct 29 2012, 9:03 am
Newsgroups: comp.lang.python
From: Christian <mining.fa...@googlemail.com>
Date: Mon, 29 Oct 2012 06:03:44 -0700 (PDT)
Local: Mon, Oct 29 2012 9:03 am
Subject: Re: SSH Connection with Python
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian  
View profile  
 More options Oct 29 2012, 9:03 am
Newsgroups: comp.lang.python
From: Christian <mining.fa...@googlemail.com>
Date: Mon, 29 Oct 2012 06:03:44 -0700 (PDT)
Local: Mon, Oct 29 2012 9:03 am
Subject: Re: SSH Connection with Python
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Oct 29 2012, 9:10 am
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Mon, 29 Oct 2012 09:10:57 -0400
Local: Mon, Oct 29 2012 9:10 am
Subject: Re: SSH Connection with Python
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.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Robinow  
View profile  
 More options Oct 29 2012, 11:18 am
Newsgroups: comp.lang.python
From: David Robinow <drobi...@gmail.com>
Date: Mon, 29 Oct 2012 11:18:38 -0400
Local: Mon, Oct 29 2012 11:18 am
Subject: Re: SSH Connection with Python
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]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 29 2012, 5:44 pm
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Mon, 29 Oct 2012 22:44:09 +0100
Local: Mon, Oct 29 2012 5:44 pm
Subject: Re: SSH Connection with Python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gelonida N  
View profile  
 More options Oct 29 2012, 5:51 pm
Newsgroups: comp.lang.python
From: Gelonida N <gelon...@gmail.com>
Date: Mon, 29 Oct 2012 22:51:19 +0100
Local: Mon, Oct 29 2012 5:51 pm
Subject: Re: SSH Connection with Python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Oct 29 2012, 6:08 pm
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Mon, 29 Oct 2012 18:08:36 -0400
Local: Mon, Oct 29 2012 6:08 pm
Subject: Re: SSH Connection with Python
In article <mailman.3048.1351547492.27098.python-l...@python.org>,
 Gelonida N <gelon...@gmail.com> wrote:

The other alternative is to chose your customers better :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »