def main(args): #url = args.url #user, host = url.split('@', 1) #cfg_file = os.environ['HOME'] + '/.airos-wnm/config' cfg_file = os.path.expanduser('~/.airos-wnm/config') cfg = ConfigParser() cfg.read(cfg_file) user = cfg.get("config", "user") host = cfg.get("config", "host") passwd = cfg.get("config", "pass") #passwd = cfg.get(user, host) #child = pexpect.spawn('ssh {0}'.format(url)) #child.expect('password:'******'touch test') # #print channel.read(1024) script = open("connect.sh", "r") s = ssh_session.ssh_session(user, host, passwd) s.scp("connect.sh", "connect.sh") s = ssh_session.ssh_session(user, host, passwd) s.ssh("./connect.sh")
# -*- coding: iso-8859-1 -*- import pexpect import sys import time import os from ssh_session import ssh_session TimeStamp = time.strftime("%m%d%y_%I%M%S%p", time.localtime()) host = sys.argv[1] accounts = file(sys.argv[2]) command = sys.argv[3] for line in accounts: name, password = line.strip().split(' ') session = ssh_session(name, host, password, 1) session.ssh(command)
subprocess.call([('./assign_public_ip.sh', '-s', '%s', '-u', '%s', '-p', '%s', '-i', '%s', '-n', '%s', '-g', '%s', '-b', '%s', '-d', '%s') % ( auto_razor_env['current_env']['servers'][server]['private_ip'], 'root', auto_razor_env['current_env']['servers'][server]['root_passwd'], auto_razor_env['current_env']['servers'][server]['public_ip'], '255.255.255.0', '198.101.133.1', '198.101.133.255', '8.8.8.8' )], shell=True ) """ # Now that we gave a ready model with a private IP, we need to ssh into the Razor box and run assign_public_ip.sh session = ssh_session(results.razor_username, results.razor_ip, results.razor_passwd, True) # print the state of the current session print session # Now that we gave a ready model with a private IP, we need to ssh into the Razor box and run assign_public_ip.sh session.ssh('./assign_public_ip.sh -s %s -u %s -p %s -i %s -n %s -g %s -b %s -d %s' % ( auto_razor_env['current_env']['servers'][server]['private_ip'], 'root', auto_razor_env['current_env']['servers'][server]['root_passwd'], auto_razor_env['current_env']['servers'][server]['public_ip'], '255.255.255.0', '198.101.133.1', '198.101.133.255', '8.8.8.8') )
# -*- coding: iso-8859-1 -*- import pexpect import sys import time import os from ssh_session import ssh_session TimeStamp = time.strftime("%m%d%y_%I%M%S%p", time.localtime()) host = sys.argv[1] accounts = file(sys.argv[2]) directory = sys.argv[3] dest = sys.argv[4] for line in accounts: name, hint, password = line.split('\t') print name session = ssh_session(name, host, password, 1) session.scp(directory, dest)
# Get the password for the host parser.add_argument('--user_passwd', action="store", dest="user_passwd", required=True, help="Non-root password for the host") # Get the password for the host parser.add_argument('-v', action="store", dest="verbose", default=None, help="Verbose") # Parse the parameters results = parser.parse_args() filename=os.path.basename(results.source) # Download the set-up script print " %s ==> %s:%s" % (results.source, results.host_name, results.destination) # Connect to the host session = ssh_session(results.user_name, results.host_name, results.user_passwd, results.verbose) session.scp(results.source, results.destination) print "chmod 0755 %s" % results.destination session.ssh('chmod 0755 %s/%s' % (results.destination, filename)) # Run the script print "Running the script: %s" % results.destination session.sudo_ssh('sudo %s/./%s' % (results.destination, filename)) session.close() print "!!## -- Ending Setup for Bare Metal -- ##!!"
required=True, help="Non-root password for the host") parser.add_argument('--zodiac_host_id', action="store", dest="zodiac_host_id", required=True, help="Host ID from the zodiac ") # Get the password for the host parser.add_argument('-v', action="store", dest="verbose", default=None, help="Verbose") # Parse the parameters results = parser.parse_args() # Connect to the host print "Setting up session" session = ssh_session(results.user_name, results.ip, results.user_passwd, results.verbose) print "Running zodiac...." print 'bash /opt/zodiac/runZodiac.sh %s' % (results.zodiac_host_id) session.ssh('bash /opt/zodiac/runZodiac.sh %s' % (results.zodiac_host_id)) session.close() print "!!## -- Ending Setup for Bare Metal -- ##!!"
def launch(host, username, passwvord, command): session = ssh_session(username, host, password, 1) session.ssh('nohup %s > /dev/null 2> /dev/null < /dev/null &' % command)