[root@node110 paramiko]# cat simple1.py
#!/usr/bin/env python
import paramiko
hostname='192.168.2.120'
username='root'
password='123456'
paramiko.util.log_to_file('syslogin.log')
ssh=paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.connect(hostname=hostname,username=username,password=password)
stdin,stdout,stderr=ssh.exec_command('free -m')
print stdout.read()
ssh.close()
结果:
[root@node110 paramiko]# python simple1.py
total used free shared buffers cached
Mem: 486 182 304 4 17 56
-/+ buffers/cache: 107 378
Swap: 2015 0 2015
2017-04-10
登录远程SSH并返回执行结果SSHClient
评论
发表评论
姓 名: