Advertisement

07.27.2005 at 07:01PM PDT, ID: 21507060
[x]
Attachment Details

SSH in python

Asked by Mytix in Python Scripting Language

Tags: python, ssh

Hi all,
Im trying to build a custom SSh client in python using sockets in windows.
below is a snippet of my function in the code

#!/usr/bin/env python
import os
import sys
from socket import *


localPortNo=8000
maxTries=10
blockSize=65536*16

def createTCPSocketSSH (remoteHostname, remotePort=22, localPort=-1):
    global localPortNo
    if localPort == -1:
        localPort = localPortNo
        localPortNo = localPortNo+1
    tryNo = 1
    while 1:
        command = "ssh -f -g -A -X %s\n" \
                  % (remoteHostname)        
        result = os.system(command)
        if result == 0:
            break
        localPortNo = localPortNo+1
        tryNo = tryNo + 1
        if tryNo == maxTries:
            os.exit(1)


    # create a TCP socket which connects to our ssh pipe
    s = socket(AF_INET, SOCK_STREAM)
    s.connect(("localhost", localPort))
    return s

It seems that everytime I run it, it give me this error
" 'ssh' is not recognized as an internal or external command, operable program or batch file. "
What is causing this? Are there any other examples of SSH clients using sockets? Im trying to use twisted framework but it seems to be unstable ( cant login twice). Any help on either is greatly appriciated!
Thanks
Marc

Start Free Trial
[+][-]07.28.2005 at 07:12AM PDT, ID: 14545847

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.28.2005 at 06:42PM PDT, ID: 14551459

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 07:21PM PDT, ID: 14559943

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 09:09PM PDT, ID: 14560131

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.31.2005 at 03:22PM PDT, ID: 14566481

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Python Scripting Language
Tags: python, ssh
Sign Up Now!
Solution Provided By: Traltixx
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32