Python Script: Download file over SSH

Script:

import os
import paramiko 
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.171.21.99', username="abhishek", password="golden111")
sftp = ssh.open_sftp()
lp = os.path.realpath(__file__)
localpath = 'abc.txt'
remotepath = '/opt/crestelsetup/patchzip/abc.txt'
print localpath
print remotepath
sftp.get(remotepath, localpath)
sftp.close()
ssh.close()


===================================

Notes:

Notes:

1. This downloads 'abc.txt.' from remote server to current directory.

2. This assumes that SSH port is 22, and accessible.

3. Useful if FTP port ( 21 ) is closed. 

4. For uploading file see below link:

http://pc2solution.blogspot.in/2015/04/python-script-upload-file-over-ssh.html

Comments