Guest User

Untitled

a guest
Dec 7th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #Python2.7
  2. import paramiko
  3. import time
  4.  
  5. ip_address = "192.168.100.200"
  6. username = "cisco"
  7. password = "cisco"
  8.  
  9. ssh_client = paramiko.SSHClietn()
  10. ssh_client.set_missing_host_key_policy(paramiko.AutoAddpolicy())
  11. ssh_client.connect(hostname=ip_address,username=username,password=password)
  12.  
  13. print "Succesfull Connection", ip_address
  14.  
  15. remote_connection = ssh_client.invoke_shell()
  16.  
  17. remote_connection.send("configure terminal\n")
  18. remote_connection.send("router ospf 100\n")
  19. remote_connection.send("network 0.0.0.0 0.0.0.0 area 0\n")
  20.  
  21. for vlan in range (2,21):
  22. print "Creating Vlan " + str(vlan)
  23. remote_connection.send("vlan " + str(vlan) + "\n")
  24. remote_connection.send("Name Python Vlan " + str(vlan) + "\n")
  25. time.sleep(0.5)
  26.  
  27. remote_connection.send("end\n")
  28.  
  29. time.sleep(1)
  30. output = remote_connection.recv(65535)
  31. print output
  32.  
  33. ssh_client.close
Add Comment
Please, Sign In to add comment