Guest User

Untitled

a guest
Jan 27th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import paramiko
  2. ssh = paramiko.SSHClient()
  3. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  4. try:
  5.     # I figured out the range of IPs seeing the first and the last ones in my lab
  6.     for i in range(***,***):
  7.         ip=str(i)
  8.         # This was my PC itself, hence the check :D
  9.         if(ip!="***"):
  10.             try:
  11.                 print '********'+ip
  12.                 ssh.connect('********'+ip, username='user',password='******')
  13.                 stdin, stdout, stderr = ssh.exec_command("reboot")
  14.             except:
  15.                 print "ip not there"
  16. except:
  17.     # The IP might not be available
  18.     error=1
Add Comment
Please, Sign In to add comment