-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathssh.py
More file actions
executable file
·25 lines (23 loc) · 777 Bytes
/
Copy pathssh.py
File metadata and controls
executable file
·25 lines (23 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
#! --* coding: utf-8 *--
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("lofyer.org",22,"root", "password")
stdin, stdout, stderr = ssh.exec_command("ls /")
print stdout.readlines()
ssh.close()
t = paramiko.Transport(("主机","端口"))
t.connect(username = "用户名", password = "口令")
sftp = paramiko.SFTPClient.from_transport(t)
remotepath='/var/log/system.log'
localpath='/tmp/system.log'
sftp.get(remotepath, localpath)
t.close()
t = paramiko.Transport(("主机","端口"))
t.connect(username = "用户名", password = "口令")
sftp = paramiko.SFTPClient.from_transport(t)
remotepath='/var/log/system.log'
localpath='/tmp/system.log'
sftp.put(localpath,remotepath)
t.close()