D
D
DVoropaev2019-12-13 00:05:24
Python
DVoropaev, 2019-12-13 00:05:24

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

1 answer(s)
V
Vadim Shatalov, 2019-12-13
@netpastor

Try to add

try:
...
finnaly:
    ssh.close()

docs.paramiko.org/en/2.6/api/client.html#paramiko....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question