Answer the question
In order to leave comments, you need to log in
Why does paramiko hang in python3?
In some cases (in which ones - not installed, difficult to reproduce)) hangs in this line:
ssh.connect(target, port = sshpo
def connect(target, sshport, user, password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(target, port = sshport, username = user, password = password, timeout=5, banner_timeout = 5, auth_timeout=5)
resultCode = 1
except paramiko.AuthenticationException:
resultCode = 0
except socket.error:
resultCode = 2
Answer the question
In order to leave comments, you need to log in
Try to add
try:
...
finnaly:
ssh.close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question