Skip to content

Instantly share code, notes, and snippets.

@ksator
Created May 18, 2020 23:09
Show Gist options
  • Save ksator/8148c2332889f51b9f9ddb77cb15aefc to your computer and use it in GitHub Desktop.
Save ksator/8148c2332889f51b9f9ddb77cb15aefc to your computer and use it in GitHub Desktop.
ssh arista EOS devices using paramiko
'''
python -V
Python 3.7.7
pip freeze | grep paramiko
paramiko==2.7.1
'''
import paramiko
import time
username='arista'
password='arista'
ip = "10.83.28.124"
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip, port=22, username=username, password=password)
shell_session = client.invoke_shell()
output = shell_session.recv(65535)
print(output)
shell_session.send("show version\n")
time.sleep(1)
output = shell_session.recv(65535)
print(output)
shell_session.close()
shell_session.closed
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment