简体   繁体   中英

Copy file/folder from windows to Linux PC using SCP Command

I want to copy a few folders from Windows PC to Linux machine. I am using Putty and connected to my Linux PC. In PuTTY, i executed following command where i am trying to copy files from Windows folder path to the present folder in Linux:

scp -r user_name@IPAddr_Windows_PC:C:\Test\Folder .

I am getting a `connection refused error. Please let me know if anything is wrong with the command that i am using. I need the correct command, since i have to develop a script.

The scp command executing on the linux machine assumes there is an sshd daemon server running on the target machine which will open up port 22 and listen for incoming ssh requests. A file transfer subsystem (sftp in linux, don't know what the Windows equivalent is) will then be launched by the sshd daemon to respond to the file transfer request.

The "connection refused" is caused by no process listening to port 22 on the Windows machine.

You should probably consider initiating the transfer in the reverse direction (as in the scp suggestion above). Another option would be to use "rsync". On Linux rsync is a common tool, and for Windows you can find rsync compatible programs written in Python.

The rsync command would look something like this:

rsync C:/mydocuments/myfiles/ my.linux.machine::myfiles

This example assumes an rsync daemon is available on the target machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM