AshA
AshA

Reputation: 289

How to Transfer Files from Client to Server Computer by using python script?

Can Any one help me out how can I do this??

Upvotes: 2

Views: 10053

Answers (2)

Jayanthi
Jayanthi

Reputation: 45

I used the same script, but my host failed to respond. My host is in different network.

WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Upvotes: -1

Burhan Khalid
Burhan Khalid

Reputation: 174708

paramiko provides a SFTPClient that can be used to do this.

import paramiko

source = r'C:\Somedir\somefile.txt'
dest = r'/home/user/file.txt'
hostname = 'linux.server.com'
port = 22 # default port for SSH
username = 'user'
password = 'secret'

try:
    t = paramiko.Transport((hostname, port))
    t.connect(username=username, password=password)
    sftp = paramiko.SFTPClient.from_transport(t)
    sftp.put(source, dest)
finally:
    t.close()

Upvotes: 5

Related Questions