Skip to content

Commit 7f517b9

Browse files
authored
Create paramiko_cmd.py
1 parent 4395b3a commit 7f517b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: day-042/paramiko_cmd.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import paramiko
2+
3+
4+
ssh = paramiko.SSHClient()
5+
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
6+
ssh.connect("IP","端口号","用户名", "密码")
7+
# # 执行命令
8+
catin, catout,caterr = ssh.exec_command('cd data;cat paramiko.txt')
9+
# # 结果放到stdout中,如果有错误将放到stderr中
10+
print(catout.read().decode('utf-8'))
11+
ssh.close()

0 commit comments

Comments
 (0)