1 import paramiko,os,sys 2 3 ip = raw_input("input ip address :>>>") 4 password = raw_input("input password:>>>") 5 cmd = raw_input("input your cmd:>>> ") 6 7 print ''' 8 ------connecting to %s ,-------- 9 '''%ip 10 def ssh_cmd(ip,port,cmd,user,passwd): 11 result = "" 12 try: 13 ssh = paramiko.SSHClient() 14 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 15 ssh.connect(ip,port,user,passwd) 16 stdin, stdout, stderr = ssh.exec_command(cmd) 17 result = stdout.read() 18 print result 19 ssh.close() 20 except: 21 print "ssh_cmd err." 22 return result