Copy files from unix to windows

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/A...

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

Guy Avraham's user avatar

Guy Avraham

3,3623 gold badges40 silver badges49 bronze badges

asked Apr 19, 2012 at 19:56

user1344963's user avatar

5

This one worked for me.

scp /home/ubuntu/myfile username@IP_of_windows_machine:/C:/Users/Anshul/Desktop 

answered Mar 12, 2018 at 6:04

emoblazz's user avatar

emoblazzemoblazz

1,3111 gold badge6 silver badges3 bronze badges

6

Download pscp from Putty download page, then use it from Windows Command Line CMD as follows:

pscp username_linux_machine@ip_of_linux_machine:/home/ubuntu/myfile.ext C:UsersNameDownloads

Copying starts once you enter the password for the Linux machine.

ifnotak's user avatar

ifnotak

3,8673 gold badges21 silver badges35 bronze badges

answered Jun 8, 2016 at 20:49

Hesham Eraqi's user avatar

Hesham EraqiHesham Eraqi

2,4254 gold badges22 silver badges45 bronze badges

3

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

fluffyBatman's user avatar

fluffyBatman

6,3443 gold badges22 silver badges24 bronze badges

answered Jun 10, 2014 at 11:57

Chris Alexander sebastian's user avatar

8

Access from Windows by Git Bash console (also works for CMD and PowerShell):

scp user@ip:/dir1/dir2/file "D:dir1dir2"

Wenfang Du's user avatar

Wenfang Du

7,3707 gold badges49 silver badges79 bronze badges

answered Jan 4, 2019 at 13:18

byteprom's user avatar

byteprombyteprom

4514 silver badges4 bronze badges

5

You could use something like the following

scp -r linux_username@linux_address:path/to/file path/to/local/directory

This will copy file to the specified local directory on the system you are currently working on.

The -r flag tells scp to recursively copy if the remote file is a directory.

answered Feb 16, 2015 at 23:58

Atif's user avatar

AtifAtif

3251 gold badge4 silver badges16 bronze badges

Windows doesn’t support SSH/SCP/SFTP natively. Are you running an SSH server application on that Windows server? If so, one of the configuration options is probably where the root is, and you would specify paths relative to that root. In any case, check the documentation for the SSH server application you are running in Windows.

Alternatively, use smbclient to push the file to a Windows share.

George's user avatar

George

6,5193 gold badges42 silver badges56 bronze badges

answered Apr 19, 2012 at 19:59

theglauber's user avatar

theglaubertheglauber

27.9k7 gold badges29 silver badges46 bronze badges

5

For all, who has installed GiT completly with «Git Bash»: You can just write:

scp login@ip_addres:/location/to/folders/file.tar .

(with space and DOT at the end to copy to current location). Than just add certificate (y), write password and that’s all.

answered Oct 3, 2017 at 12:31

Krzysztof Walczewski's user avatar

1

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.

answered Feb 19, 2019 at 12:09

Baris Vvolf's user avatar

I had to use pscp like above Hesham’s post once I downloaded and installed putty. I did it to Windows from Linux on Windows so I entered the following:

c:ssl>pscp username@linuxserver:keenan/ssl/* .

This will copy everything in the keenan/ssl folder to the local folder (.) you performed this command from (c:ssl). The keenan/ssl will specify the home folder of the username user, for example the full path would be /home/username/keenan/ssl. You can specify a different folder using a forward slash (/), such as

c:ssl>pscp username@linuxserver:/home/username/keenan/ssl/* .

So you can specify any folder at the root of Linux using :/.

halfer's user avatar

halfer

19.7k17 gold badges95 silver badges183 bronze badges

answered Dec 14, 2018 at 12:47

Keenan Stewart's user avatar

To send a file from windows to linux system

scp path-to-file user@ipaddress:/path-to-destination

Example:

scp C:/Users/adarsh/Desktop/Document.txt root@127.0.0.1:/tmp

keep in mind that there need to use forward slash(/) inplace of backward slash() in for the file in windows path else it will show an error

C:UsersadarshDesktopDocument.txt: No such file or directory

.
After executing scp command you will ask for password of root user in linux machine.
There you GO…

To send a file from linux to windows system

scp -r user@ipaddress:/path-to-file path-to-destination

Example:

scp -r root@127.0.0.1:/tmp/Document.txt C:/Users/adarsh/Desktop/

and provide your linux password.
only one you have to add in this command is -r.
Thanks.

answered Mar 15, 2019 at 6:00

ADARSH K's user avatar

ADARSH KADARSH K

5967 silver badges20 bronze badges

Here is the solution to copy files from Linux to Windows using SCP without password by ssh:

  1. Install sshpass in Linux machine to skip password prompt

  2. Script

    sshpass -p 'xxxxxxx' scp /home/user1/*.* testuser@x.x.x.x:/d/test/

Details:

sshpass -p 'password' scp /source_path/*.* windowsusername@windowsMachine_ip:/destination_drive/subfolder/

serenesat's user avatar

serenesat

4,59110 gold badges35 silver badges53 bronze badges

answered Aug 28, 2015 at 12:47

Ramarajan Jothi's user avatar

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-mojbd3ndcc_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-mojbd3ndgenetic_map_data: I needed to transfer to an external HDD, thus I had to give permissions of sharing to this device.

answered Jun 27, 2019 at 3:37

giannkas's user avatar

giannkasgiannkas

1683 silver badges14 bronze badges

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.

answered Apr 7, 2019 at 6:02

Zenith's user avatar

ZenithZenith

9371 gold badge8 silver badges21 bronze badges

I know this is old but I was struggling with the same. I haven’t found a way to change directories, but if you just want to work with the C drive, scp defaults to C. To scp from Ubuntu to Windows, I ended up having to use (notice the double back-slashes):

scp /local/file/path user@111.11.11.111:Users\Anshul\Desktop

Hope this helps someone.

Racil Hilan's user avatar

Racil Hilan

24.2k12 gold badges49 silver badges52 bronze badges

answered Jul 29, 2016 at 0:35

Acmag's user avatar

AcmagAcmag

12 bronze badges

2

Try this:

scp /home/ubuntu/myfile C:usersAnshulDesktop

Pang's user avatar

Pang

9,344146 gold badges85 silver badges121 bronze badges

answered Jan 12, 2013 at 2:50

Corey Burnett's user avatar

Corey BurnettCorey Burnett

7,2629 gold badges54 silver badges92 bronze badges

1

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

answered Sep 4, 2012 at 7:38

user1645422's user avatar

Assuming that, the Windows box have a shared folder. You can use smbclient command.
Which provide a FTP-like command line interface over the SMB protocol.

This post provide a ready to use example, which looks a perfect answer.

If you need to copy files to or from a windows server from a unix server, you can use an utility from the Samba software suite called smbclient.

Here is an example to copy a file to a Windows server:

 smbclient //WIN_SERVER/SHARE -l WIN_SERVER_IP -A AUTHFILE -c "put
 TRANSFER_FILE_LOCAL TRANSFER_FILE_REMOTE"

where:

WIN_SERVER = the name of your Windows server

SHARE = the name of your Windows share

WIN_SERVER_IP = the IP address of your Windows server

AUTHFILE = full path to your authentication file name. The file
contents should include:

username = mywinuser
password = mywinpass
domain = MYDOMAIN

TRANSFER_FILE_LOCAL = full path to Unix file to transfer

TRANSFER_FILE_REMOTE = new file name on Windows server

For more help or options using smbclient, type «smbclient -h»

I am trying to copy one file from Linux (CentOS) to Windows.

scp file.txt administrator@x.x.x.x:C:/

The output I get is:

ssh: connect to host x.x.x.x port 22: Connection refused
lost connection

x.x.x.x is the IP of my Windows machine. Port 22 is open but I cannot connect via telnet from CentOS to Windows

curl -v x.x.x.x:22

* About to connect() to 10.109.10.135 port 22 (#0)
*   Trying 10.109.10.135... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

The firewall is disabled on Windows and Port 22 is open. I can connect via putty client to CentOS on that port. I’m quite confused here.

Thanks.

hyph's user avatar

hyph

2812 silver badges13 bronze badges

asked Mar 28, 2017 at 20:22

suhas savkoor's user avatar

5

The fact that you can initiate a connection from the windows box to the Linux box does in no way imply that the reverse is possible as well.

If you want to be able to scp to your Windows machine, you need to make sure you have a SSH service running on your Windows machine which allows for incoming ssh connections. The fact that you get a ‘connection refused’ message suggests that that isn’t set up or the service is not started.

Since you share that you’ve been able to reach your Linux machine using ssh, it’s probably easier to just turn things around, and run scp on the Windows machine instead.

answered Mar 28, 2017 at 23:14

Wouter Verhelst's user avatar

1

I’ve would simply implement ftp or sftp server on the Windows side (installation will open port for u) and do it this way. It will get job done much easier. With no NTFS issues etc.

answered Mar 29, 2017 at 11:06

nethero's user avatar

Download pscp in windows and use

pscp -P 801 machine@192.xxx.xx.x:/root/filename.txt ./

-P is the option to supply a port number.

jesse_b's user avatar

jesse_b

34.6k10 gold badges87 silver badges136 bronze badges

answered Jan 4, 2020 at 16:06

Ravindra Prajapati's user avatar

1

You could as well mount the windows computer’s drive as smb share via cifs on your linux machine and perform a local copy.

answered Jan 4, 2020 at 17:52

jf1's user avatar

jf1jf1

3971 silver badge10 bronze badges

IN THIS TASK

  • SUMMARY

    • Configuring the UNIX Host

    • Transfer a Single File

    • Transfer a Whole Directory

  • REFERENCES

Summary

The remote copy (RCP) tool is a standard UNIX tool and a Microsoft Windows 2000 tool. You can use this tool to transfer a file and recursively transfer the whole directory between two computers.

Configuring the UNIX Host

Before you can use the RCP tool from a Windows-based computer, you must turn on the RCP service and update the security files to allow the Windows-based computer to connect to your computer over this service.

To turn on the RCP service by using inetd:

  1. Log on to the computer as root.

  2. Edit the file /etc/Inetd.conf.

  3. Uncomment the lines that start with shell and that start with exec.

  4. Save the file.

  5. Send the Host User Profile (HUP) signal to inetd by using kill or by using pkill. Use ps to determine the process ID.

  6. Run inetd again.

To turn on the RCP service by using xinetd:

  1. Log on to the computer as root.

  2. Edit the file /etc/Xinetd.d/rsh.

  3. Change the line disable to no.

  4. Save the file.

  5. Send the HUP signal to xinetd by using kill or by using pkill. Use ps to determine the process ID.

  6. Run xinetd again.

You must now set the security permissions to allow the Windows host to connect to your computer:

  1. Edit the file /etc/Hosts.equiv.

  2. Add a line that contains the name of your Windows host.

  3. Add a second line that contains the name of your Windows host and the name of a user who can access the directory that you want to transfer. Separate the two elements with a tab character.

  4. Save the file.

NOTE: To transfer files from some UNIX computers, you must log on to the Windows-based computer as the user that you set in the file Hosts.equiv.

Transfer a Single File

To transfer a single file, you must supply the hostname, the username, the path of the source file, and the path of the destination file that you want the file copied to. For example, to copy the file Index.html from the path /usr/local/htdocs on the computer unixhost as the user webuser you must use:

rcp unixhost.webuser:/usr/local/htdocs/index.html index.html

Transfer a Whole Directory

To transfer a whole directory, which includes all of the directory contents and subdirectories, add the -r command line option to the command. For example, to copy the whole Htdocs directory from your UNIX computer to the directory C:inetpubunixweb you must use:

rcp -r unixhost.webuser:/usr/local/htdocs C:InetPubUnixWeb

References

For additional information about preparing to move data for a migration from UNIX to Windows, click the article number below to view the article in the Microsoft Knowledge Base:

324538 HOW TO: Migrate Web Site Data in a UNIX-to-Windows Migration

Need more help?

В статье мы расскажем, как копировать файлы в Windows и Linux-системах, и покажем основные команды, с помощью которых происходит передача файлов по SSH.

Для копирования файлов по SSH в Linux-системах и Windows используют разные инструменты:

  • scp (Secure CoPy) — утилита для безопасного копирования данных между Linux-системами по протоколу SSH. Она входит в состав OpenSSH, поэтому для работы с утилитой не нужно устанавливать дополнительное ПО;
  • pscp.exe — утилита для загрузки файлов по SSH в ОС Windows. Она обладает теми же возможностями, что и scp. Утилита входит в состав программы Putty — SSH-клиента для Windows. Скачать программу можно по ссылке.

Обратите внимание

Если файл, который вы хотите скопировать, уже существует на целевом хосте, при копировании он будет перезаписан.

Копирование файлов по SSH на Linux

Для Linux копирование файлов по SSH происходит с использованием команды scp. С её помощью можно копировать файлы:

  • с локального компьютера на удалённый сервер,
  • с удалённого сервера на локальный компьютер,
  • с одного удалённого сервера на другой.

Общий вид команды:

scp [опция] [источник] [получатель]

Обратите внимание

Для подключения к удалённому серверу вам понадобится логин и пароль пользователя.

Как скопировать файл по SSH с локальной машины на удалённый сервер

Как загрузить файл на сервер по SSH? Для этого используйте команду вида:

scp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]

Пример команды:

scp /home/test.txt root@123.123.123.123:/directory

Файл test.txt будет скопирован на хост 123.123.123.123 в директорию «/directory».

Как скопировать файлы с удалённого сервера на локальный компьютер

При подключённом SSH скачать файл на локальный компьютер с удалённого сервера можно с помощью команды:

scp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]

Пример команды:

scp root@123.123.123.123:/home/test.txt /directory

Файл test.txt будет загружен с сервера 123.123.123.123 на локальный компьютер в папку «/directory».

Как скопировать файл по SSH с одного удалённого сервера на другой

Подключитесь по SSH к серверу, на котором расположен файл. Затем выполните команду:

scp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]

Пример команды:

scp /home/test.txt root@123.123.123.123:/directory

Файл test.txt будет скопирован на хост 123.123.123.123 в директорию «/directory».

Как скачать папку со всеми файлами и подпапками

Если вы хотите скачать папку со всеми файлами и подпапками, используйте ключ -r:

scp -r [источник] [получатель]

Как подключиться к серверу по нестандартному порту

Бывает, что для подключения по SSH нужно указать нестандартный порт. Без указания порта команда подключается к серверу по стандартному 22 порту. Чтобы указать нестандартный порт, введите команду с ключом -P:

scp -P [источник] [получатель]

Пример команды:

scp -P 12345 /home/test.txt root@123.123.123.123:/directory

Эта команда подключается по порту 12345 к серверу 123.123.123.123 и копирует на него файл «test.txt» с локального компьютера в директорию «/directory».

Как передать и скачать файлы по SSH на Windows

Скопировать файл по SSH на сервер можно командой:

pscp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]

Скачать файл по SSH с сервера командой:

pscp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]

Увидеть список папок и файлов на сервере можно через pscp.exe. Для этого введите:

pscp -ls [имя пользователя]@[имя сервера/ip-адрес]:[путь]

Если в пути или в названии файла есть пробелы, используйте кавычки:

pscp “C:files or docsfile name” root@123.123.123.123:/home

This is a command question among the Unix beginners and windows administrator that how to copy the files from windows to Unix operating system and vise-verse.In all the Unix/Linux operating system supports secure shell which is widely used.Its very secured compared to telnet and ftp. By default ssh uses the port 22. SFTP (secure file transfer protocol  & SCP (secure copy) also uses the same port. 

But windows operating system will not support ssh and there is no in-built ssh client to communicate to Unix machine.There is open source free software called WinSCP which supports SFTP client, SCP client, FTPS client and FTP client for Windows.

You can download the WinSCP from the below link.

The following screen shot will show you how to use winscp.

Open the winscp after installing it . 

By clicking the New tab you can start the new SFTP/SCP session.

In the hostname field you can enter hostname or IP address of the remote Unix machine .

In user name field,you need to enter remote Unix machine user name and enter password in the password field.

Note:Allow SCP fallback option, will re-connect to the remote host automatically if disconnects abnormally. 

In File protocol, you can either select SFTP or SCP .Both the protocol will use port 22 .

You will get below screen ,after logging in.

To copy the files ,you can just drag it . 

You will be prompted for copying the files. By clicking the transfer settings ,you can select the transfer file type like binary or text.

Once the copying is done,you can disconnect the session by choosing session->disconnect.

By using WINSCP tool we can easily transfer files from Unix to windows and windows to Unix operating system.

Thank you for reading this article .Please leave a comment if you have any doubt .I will get back to you.

Reader Interactions

In this updated guide, I will walk you through the steps to copy files from Windows to Linux using easy-to-follow steps.

I will show you two ways to copy files from windows to Linux

  1. Using command line with pscp
  2. Using GUI FTP utility.

Copy File from Windows To Linux Using PSCP

It is not always that you will need to copy a file from Windows to Linux or vice versa.

But at times when you are automating things or trying to achieve some copy functionality using a script, it is good to have a utility to do that.

Here is where pscp comes into play. Using pscp you can copy the file to/from windows and Linux.

Step 1: Download pscp.exe from here. Select the appropriate package.

Download pscp to copy files from windows to Linux

Step 2: copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:WindowsSystem32 path.

C folder location to save pscp.exe file

Step 3: Open Windows PowerShell and use the following command to verify if pscp is accessible from the path.

pscp

You should see the following output.

Step 4: Use the following format to copy the single file from Windows to the Linux box.

pscp -pw password C:UsersAdminDesktoptest.txt  
[email protected]:/home/vagrant

Here is the explanation of the command.

  1. -pw for the password.
  2. Replace password with the Linux user password.
  3. C:UsersAdminDesktoptest.txt represents the path of the file that has to be copied to the Linux system.
  4. 192.168.33.10 is the IP of the Linux server.
  5. /home/vagrant is the user-accessible path in the Linux system to copy the file.

If you want to copy all the files in a directory to Linux, you need to add a start to the folder. eg. folder*. An example is shown below.

pscp -pw password C:UsersAdminDesktopfolder*  
[email protected]:/home/vagrant

If you are using Linux private keys for authentication, you can use -i flag instead of -pw followed by the path to the .ppk , .pem or id_rsa file.

If your key file is in pem format, you can use the puttygen command to convert it to ppk. See this ec2 server guide for the pem to ppk conversion.

Info: Learn Linux & Windows administration from Pluralsight with its 10 days free account

For Linux Private key-based authentication, the command looks like below.

pscp -i /path/to/key.ppk C:UsersAdminDesktoptest.txt 
[email protected]:/home/vagrant

Copy File From Linux To Windows Using PSCP

You can use pscp to copy files from Linux to windows. use the following command format for the same.

pscp -pw password [email protected]:/path/to/file 
C:UsersAdminDesktop

The above command will copy the file in Linux from the specified path to the Windows desktop.

Copy File from Windows To Linux Using FTP GUI

If you are not familiar with the Windows command line, you can use an FTP tool like Filezilla.

This tool is really helpful if you are working with Web Hosting providers to upload your website files from your local workstation.

You can download Filezilla from here –> FileZilla Download.

After download, install Filzill as you install any other windows software.

After installation, open the Filezilla app and enter the remote Linux server details as shown below. It will connect to the server and shows the remote server files in the file explorer.

Transfer files from windows to Linux using FTP

To upload a file, all you have to do is do a right-click and click upload, as shown in the image below. The file will get uploaded to the remote path, which is opened in the Filezilla explorer. You can also change the remote path from Filezilla.

Upload files from windows to Linux using Filezilla

Conclusion

I have shown two best and recommended ways to transfer files from Windows to Linux and vice versa.

If you face any issues while copying files, please drop the issues as a comment. I will look into it.

He loves to write about WordPress and cloud hosting. He is a Cloud Architect by profession with experience hosting high scale applications on Amazon and Google cloud platforms. He has successfully set up and grown several WordPress websites by following good tech practices.

For those computer users that have both Unix and Window’s operating systems, you should know that you can easily copy your Unix files from a Unix computer and transfer them to a Windows computer.

Using Client for NFS, you can transfer any existing Unix files from your Unix server to a Windows based server. It should also be noted that once you send the file system or folder from the Unix server to the Window’s server, you can then move either whole folder trees in just one single step.

Transferring Unix Files Using Client for NFS

One of the easiest ways to transfer Unix files to a Windows server is with the use of Client for NFS. You can easily use the “exportfs” command to make available the Unix files. Once these Unix files are available on the Unix server, you can then simply use Window’s Explorer to move the files to its server.

What is Client for NFS?

Windows NFS Client is a file sharing utility. With this software you can achieve high performance in connectivity and networking access. Client for NFS is compatible with Windows 95, 98, ME, NT, 2000 and XP.

Transfer the Unix files to the Windows Server

You can transfer the Unix files to the Windows server by using root permissions. The command you should use to export the folder tree or the file system that contains your files is “exportfs-v full_folder_path”. It should be noted that exporting a parent or child folder that already resides on the same file system currently being exported is not allowed.

  • Step 1. Make the files on your Linux computer readable for all users
  • Step 2. Launch your Windows based server
  • Step 3. Once Windows has launched, open Windows Explorer
  • Step 4. Within NFS network expand Default LAN
  • Step 5. Select the Unix server that you want to transfer files from
  • Step 6. Now, right click the folder that you would like to export and select Copy
  • Step 7. Now, right click on the target folder on your windows computer and simply paste the copied files.
  • Step 8. The file transfer should be complete.

Понравилась статья? Поделить с друзьями:
  • Copy files from linux to remote windows
  • Copy files from iphone to windows
  • Copy file from mac to windows
  • Copy con в командной строке windows
  • Copy c windows system32 utilman exe c