SSH to the network device

As usual, in every Python module, we first need to import it into our Python script, then we will create an SSH client by inheriting from SSHClient(). After that, we will configure the Paramiko to automatically add any unknown host-key and trust the connection between you and the server. Then, we will use the connect function and provide the remote host credentials:

#!/usr/bin/python__author__ = "Bassim Aly"__EMAIL__ = "basim.alyy@gmail.com"import paramikoimport timeChannel = paramiko.SSHClient()Channel.set_missing_host_key_policy(paramiko.AutoAddPolicy())Channel.connect(hostname="10.10.88.112", username='admin', password='access123', look_for_keys=False,allow_agent=False)shell = Channel.invoke_shell()
AutoAddPolicy() ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.