Giles Brown
2010-08-12 13:28:13 UTC
Hi all,
I'm new to using paramiko. I'm trying to get paramiko to give up when it
encounters a badly behaved server (see below). Can anyone give me a tip on
how to do this and whether it is possible?
The client is running on Windows and so is the server. I've tried this with
1.7.6 under Python 2.6 and 1.7.1 under Python 2.3 with the same result in
both cases.
Thanks.
Cheers,
Giles
testhang.py
"""
import paramiko
ssh = paramiko.SSHClient()
# This hangs...
ssh.connect('127.0.0.1', username='dontcare', password='dontcare',
timeout=10.0)
"""
"""
badserver.py
"""
import sys
import time
import SocketServer
class BadHandler(SocketServer.BaseRequestHandler):
""" Demonstrate bad SSH server behaviour.
"""
def handle(self):
self.request.send('SSH-1.99-USHA SSHv0.1\n')
# Uh-oh. I'm going to wait here forever!
try:
time.sleep(1000000)
except KeyboardInterrupt:
pass
if __name__ == "__main__":
server = SocketServer.TCPServer(('127.0.0.1', 22), BadHandler)
server.handle_request()
"""
I'm new to using paramiko. I'm trying to get paramiko to give up when it
encounters a badly behaved server (see below). Can anyone give me a tip on
how to do this and whether it is possible?
The client is running on Windows and so is the server. I've tried this with
1.7.6 under Python 2.6 and 1.7.1 under Python 2.3 with the same result in
both cases.
Thanks.
Cheers,
Giles
testhang.py
"""
import paramiko
ssh = paramiko.SSHClient()
# This hangs...
ssh.connect('127.0.0.1', username='dontcare', password='dontcare',
timeout=10.0)
"""
"""
badserver.py
"""
import sys
import time
import SocketServer
class BadHandler(SocketServer.BaseRequestHandler):
""" Demonstrate bad SSH server behaviour.
"""
def handle(self):
self.request.send('SSH-1.99-USHA SSHv0.1\n')
# Uh-oh. I'm going to wait here forever!
try:
time.sleep(1000000)
except KeyboardInterrupt:
pass
if __name__ == "__main__":
server = SocketServer.TCPServer(('127.0.0.1', 22), BadHandler)
server.handle_request()
"""