Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, paramiko
- if len(sys.argv) < 3:
- print "usage: SFTP_test.py server_address local_file_to_upload"
- server_address = sys.argv[1]
- source_file = sys.argv[2]
- dest_file = source_file
- username = 'student'
- password = 'student'
- port = 22
- # create a Transport object with the IP address of the server and the port (Port 22 for SSH)
- t = paramiko.Transport((server_address, port))
- # connect to the server with the username student and password student
- t.connect(username=username, password=password)
- # create an SFTP client from the Transport socket object
- sftp = paramiko.SFTPClient.from_transport(t)
- # upload the source file and call it the name stored in dest_file on the server
- sftp.put(source_file, dest_file)
- # close the socket/connection
- t.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement