#pythonPython2.6.6(r266:84292,Oct122012,14:23:48)[GCC4.4.620120305(RedHat4.4.6-4)]onlinux2脚本如下:#!/usr/bin/envpythonimportparamikossh_ip='192.168.42.19'ssh_port=10027...
# python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
脚本如下:
#!/usr/bin/env python
import paramiko
ssh_ip='192.168.42.19'
ssh_port=10027
ssh_uname='rhuser'
ssh_passwd='rh#0417'
paramiko.util.log_to_file('/log.log')
s = paramiko.SSHClient()
s.load_system_host_keys()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connection(ssh_ip, ssh_port, ssh_uname, ssh_passwd)
stdin, stdout, stderr = s.exec_command('ifconfig')
print stdout.read()
s.close()
脚本执行后报错如下: