Python Forum
'SSHClient' object is not callable - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: 'SSHClient' object is not callable (/thread-38964.html)



'SSHClient' object is not callable - 3lnyn0 - Dec-15-2022

Hi! Can anyone help me to fix the below error? Thanks!

Error:
File "", line 12, in <module> ssh_client(IP,port=22, username='admin', password='cisco') TypeError: 'SSHClient' object is not callable
import paramiko
with open('network/routers') as f:
        for IP in f:
                ssh_client=paramiko.SSHClient()
                ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh_client(IP,port=22, username='admin', password='cisco')

                stdin, stdout, stderr = ssh_client.exec_command('show version')
                output=stdout.read().decode()
                print(output)
                with open(IP + '_output.txt', 'w') as f:
                        f.write(output)
                
                ssh_client.close()



RE: 'SSHClient' object is not callable - deanhystad - Dec-15-2022

Did you mean to call ssh_client.connect(IP,port=22, username='admin', password='cisco')?