Guest User

Untitled

a guest
Nov 10th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import paramiko, os
  4. from getpass import getpass
  5.  
  6. # Setting Variables
  7. Hosts = [ '192.168.1.1', '192.168.1.2'] #IPs changed for posting
  8. username = 'root'
  9. print 'Enter root password on remote computer:'
  10. password = getpass()
  11. port = 22
  12. File = 'Nessus-6.11.2-es7.x86_64.rpm'
  13.  
  14. for host in Hosts:
  15. print 'Finished copying files. Now executing on remote computer'
  16.  
  17. #Setting up SSH session to run commands
  18. remote_client = paramiko.SSHClient()
  19. remote_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  20. remote_client.connect(host, username=username, password=password)
  21.  
  22. InstallNessus = 'rpm -U --percent %s'%File
  23. stdin, stdout, stderr = remote_client.exec_command(InstallNessus)
  24. stdout.channel.recv_exit_status()
  25. lines = stdout.readlines()
  26. for line in lines:
  27. print line
  28. stdin, stdout, stderr = remote_client.exec_command('systemctl restart nessusd.service')
  29.  
  30. remote_client.close()
Add Comment
Please, Sign In to add comment