Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- import time
- auth_username = 'x'
- auth_password = 'x'
- devices = {$
- 'Anlin-AH-16' : {
- 'hostname' : '192.168.254.185',
- 'port' : 22,
- 'username' : auth_username,
- 'password' : auth_password
- },
- 'Anlin-AH-14' : {$
- 'hostname' : '192.168.254.183',
- 'port' : 22,
- 'username' : auth_username,
- 'password' : auth_password
- }
- }
- def connect_to(device_name, device_data):
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(**device_data)
- remote_conn = ssh.invoke_shell()
- print('system is rebooting')
- remote_conn.send('reboot')
- time.sleep(2)
- remote_conn.send('y')
- for device_name, device_data in devices.items():
- connect_to(device_name, device_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement