import paramiko
import os
import stat
import ConfigParser
import re
from paramiko_expect import SSHClientInteraction
class My_SSHConnect():
def __init__(self, login_cred):
ip, username, password, port=22
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
def download_dir(remote_dir, local_dir):
os.path.exists(local_dir) or os.makedirs(local_dir)
dir_items = sftp.listdir_attr(remote_dir)
for item in dir_items:
# assuming the local system is Windows and the remote system is Linux
# os.path.join won't help here, so construct remote_path manually
remote_path = remote_dir + '/' + item.filename
local_path = os.path.join(local_dir, item.filename)
if S_ISDIR(item.st_mode):
download_dir(remote_path, local_path)
else:
sftp.get(remote_path, local_path)
download_dir() = download_dir('/home/eeniqsup/Eric_auto/output','/home/ashutosh/eric_auto/raw_input')
login_cred = open(r'/home/ashutosh/SCTP_Parameter/login/cred.csv').readlines()
if __name__ == '__main__':
Main()