Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import paramiko, os
- from getpass import getpass
- # Setting Variables
- Hosts = [ '192.168.1.1', '192.168.1.2'] #IPs changed for posting
- username = 'root'
- print 'Enter root password on remote computer:'
- password = getpass()
- port = 22
- File = 'Nessus-6.11.2-es7.x86_64.rpm'
- for host in Hosts:
- print 'Finished copying files. Now executing on remote computer'
- #Setting up SSH session to run commands
- remote_client = paramiko.SSHClient()
- remote_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- remote_client.connect(host, username=username, password=password)
- InstallNessus = 'rpm -U --percent %s'%File
- stdin, stdout, stderr = remote_client.exec_command(InstallNessus)
- stdout.channel.recv_exit_status()
- lines = stdout.readlines()
- for line in lines:
- print line
- stdin, stdout, stderr = remote_client.exec_command('systemctl restart nessusd.service')
- remote_client.close()
Add Comment
Please, Sign In to add comment