Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active July 5, 2016 14:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kurozumi/dfcec3fa6a97959d8d2a to your computer and use it in GitHub Desktop.
【Python】SCPで外部サーバーのファイルをローカルにコピーする方法
from paramiko import SSHClient,AutoAddPolicy
from scp import SCPClient
HOST = "203.0.113.0"
PORT = "22"
USER = "username"
PSWD = "password"
ssh = SSHClient()
ssh.set_missing_host_key_policy(AutoAddPolicy())
ssh.connect(HOST, port=PORT, username=USER, password=PSWD)
scp = SCPClient(ssh.get_transport())
scp.get("/home/User/file.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment