scp from Linux to Windows [closed]

2020-02-02 04:06发布

I am running a putty client on a Windows machine to connect successfully to a Linux box. Now I want to be able to copy a file from the Linux machine under the path /home/ubuntu/myfile to C:/Users/Anshul/Desktop on my local computer. The user at the Windows machine is anshul. I am giving the following command on putty but it is not working:

scp /home/ubuntu/myfile ip_address_of_windows_machine:C:/Users/Anshul/Desktop 

I think the path for the Windows machine is wrong. Please help as I have banged my head on a large number of forums but none seem to give correct path for Windows server. Don't suggest alternate options like WinScp

16条回答
萌系小妹纸
2楼-- · 2020-02-02 04:28

Open bash window. Preferably git bash. write

scp username@remote_ip:/directory_of_file/filename 'windows_location_you_want_to_store_the_file'

Example:

Suppose your username is jewel

your IP is 176.35.96.32

your remote file location is /usr/local/forme

your filename is logs.zip

and you want to store in your windows PC's D drive forme folder then the command will be

scp jewel@176.35.96.32:/usr/local/forme/logs.zip 'D:/forme'

**Keep the local file directory inside single quote.

查看更多
劳资没心,怎么记你
3楼-- · 2020-02-02 04:29

As @Hesham Eraqi suggested, it worked for me in this way (transfering from Ubuntu to Windows (I tried to add a comment in that answer but because of reputation, I couldn't)):

pscp -v -r -P 53670 user@xxx.xxx.xxx.xxx:/data/genetic_map/sample/P2_283/* \\Desktop-mojbd3n\d\cc_01-1940_data\

where:

-v: show verbose messages.
-r: copy directories recursively.
-P: connect to specified port.
53670: the port number to connect the Ubuntu server.
\\Desktop-mojbd3n\d\genetic_map_data\: I needed to transfer to an external HDD, thus I had to give permissions of sharing to this device.

查看更多
不美不萌又怎样
4楼-- · 2020-02-02 04:31

Your code isn't working because c:/ or d:/ is totally wrong for linux just use /mnt/c or/mnt/c

From your local windows10-ubuntu bash use this command:

for download: (from your remote server folder to d:/ubuntu) :

scp username@ipaddress:/folder/file.txt /mnt/d/ubuntu

Then type your remote server password if there is need.

for upload: (from d:/ubuntu to remote server ) :

scp /mnt/d/ubuntu/file.txt username@ipaddress:/folder/file.txt 

Then type your remote server password if there is need. note: I tested and it worked.

查看更多
贪生不怕死
5楼-- · 2020-02-02 04:33

Download pscp from Putty download page, then use it from Windows machine CMD like this:

pscp username_linux_machine@ip_of_linux_machine:/home/ubuntu/myfile.ext C:\Users\Name\Downloads

It will ask you about the username password of Linux machine, then do the copy for you.

查看更多
该账号已被封号
6楼-- · 2020-02-02 04:36

If you want to copy paste files from Unix to Windows and Windows to Unix just use filezilla with port 22.

查看更多
Ridiculous、
7楼-- · 2020-02-02 04:40

Try this, it really works.

$ scp username@from_host_ip:/home/ubuntu/myfile /cygdrive/c/Users/Anshul/Desktop

And for copying all files

$ scp -r username@from_host_ip:/home/ubuntu/ *. * /cygdrive/c/Users/Anshul/Desktop
查看更多
登录 后发表回答