Python Script: Upload 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()
localpath = 'abc.txt'
remotepath = '/opt/crestelsetup/patchzip/abc.txt'
sftp.put(localpath, remotepath)
sftp.close()
ssh.close()

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

Notes:

1. This uploads 'abc.txt.' on the remote server.

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

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

4. For downloading file, see below link:

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

Comments