import paramiko
# create ssh client
ssh_client = paramiko.SSHClient()
# remote server credentials
host = "host name here"
username = "username here"
password = "password here"
port = PORT_NUMBER
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=host, port=port, username=username, password=password)
print('connection established successfully')
ftp = ssh_client.open_sftp()
files = ftp.listdir()
print("Listing all the files and Directory: ",files)
# close the connection
ftp.close()
ssh_client.close()
Comments
Post a Comment