-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
Would be nice to have an integrated script for running commands (like reboot) on known machines that our current script returned as being problematic.
I have been working on a piece of code to do so but I've got stuck at the point we have to provide our DUO for logging in.
I've asked Aki for help. It's nice to have it there as well so anybody can come with ideas.
For now we have the following:
import paramiko
ssh = paramiko.SSHClient()
passPhrase = raw_input("What's your passphrase for private key?") #asks to provide password for passphrase
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
privkey = paramiko.RSAKey.from_private_key_file('/home/rolandmutter/.ssh/id_rsa', password=passPhrase) #locates private key and unlocks it
ssh.connect('t-yosemite-r7-230.test.releng.mdc2.mozilla.com', username='root', pkey=privkey) #main fuction to connect to host , that is hardcoded for now for test purposes
#paramiko.util.log_to_file(os.path.expanduser('/home/rolandmutter/paramiko.log'), logging.DEBUG)
stdin, stdout, stderr = ssh.exec_command('ls') # command to execute, again, hardcoded
print stdout.readlines() # prints what is shown in the machine bash
ssh.close()` # closes connection