Skip to content

Commit 2f5dd30

Browse files
committed
新增ssh客户端测试
1 parent be78456 commit 2f5dd30

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/test_paramiko.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
"""
5+
@author: zhanghe
6+
@software: PyCharm
7+
@file: test_paramiko.py
8+
@time: 2017/6/16 上午9:11
9+
"""
10+
11+
import paramiko
12+
13+
ip = '192.168.64.216'
14+
username = 'zhanghe'
15+
password = '123456'
16+
port = 22
17+
# 设置记录日志
18+
paramiko.util.log_to_file('ssh.log')
19+
# 生成ssh客户端实例
20+
s = paramiko.SSHClient()
21+
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
22+
print "Starting"
23+
s.connect(ip, port, username, password)
24+
stdin, stdout, stderr = s.exec_command('free -m')
25+
print stdout.read()
26+
s.close()
27+
28+
if __name__ == '__main__':
29+
pass

0 commit comments

Comments
 (0)