Skip to content

Instantly share code, notes, and snippets.

@jwz-ecust
Last active March 24, 2017 02:43
Show Gist options
  • Save jwz-ecust/aa79f7c2d6143d934cd2252839e92322 to your computer and use it in GitHub Desktop.
Save jwz-ecust/aa79f7c2d6143d934cd2252839e92322 to your computer and use it in GitHub Desktop.
paramiko download from linux server
import paramiko
import os
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
IP = "***********"
# port = 22
# user = "riic"
# key = "/Users/zhangjiawei/.ssh/id_dsa_138_jwzhang.jwzhang"
ssh.connect(IP, port=22, username='riic', password='****')
# stdin, stdout, stderr = ssh.exec_command('qstat -a')
stdin, stdout, stderr = ssh.exec_command('qstat -a')
# print stdout.read()
sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
work_path = "/home/riic/gdata/jwzhang/ml/surfacedos"
ml = sftp.listdir(work_path)
for i in ml:
dos_remote = work_path + "/" + i + "/step2/OUTCAR"
dos_local = "/Users/zhangjiawei/Desktop/NiPdata/NiP/dos/outcar/OUTCAR_" + i
sftp.get(dos_remote, dos_local)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment