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