Scp передать файл с windows на linux

How to get a file from my path d:/test.txt and copy it to /etc/var/test/test.txt?

I’ve tried this:

scp d:/test.txt /etc/var/test/test.txt

but that didn’t work.

How do I set the hard disk from where I copy my files?

clabacchio's user avatar

asked Mar 14, 2014 at 10:30

user3414354's user avatar

1

Umm, if you’re using cygwin you want that command to look like

scp /cygdrive/d/test.txt <linux ip>:/etc/var/test/test.txt

Or you can use WinSCP, you’ll probably find that simpler.

answered Mar 14, 2014 at 10:47

quadruplebucky's user avatar

The best way to copy files from Windows to Linux using the command line is through pscp. It is very easy and secure. For pscp to work on your windows machine, you need it add its executable to your systems path. Once it is done, you can use the following format to copy the file.

pscp -pw password D:\test.txt [email protected]:/etc/var/test/test.txt

You can refer the following blog post for more information on pscp setup.

http://comtechies.com/2016/02/copy-files-between-windows-and-linux.html

answered Feb 25, 2016 at 10:13

Bibin Wilson's user avatar

2

Assuming you are on Windows, best way is to download and install cygwin. Get the path to the binary folder and add it to the system path. You can now run Linux commands on your command line.

Open the command prompt and go to the directory where your file is that you want to copy. Run the following command;

scp file.txt [email protected]:/opt/
  • scp — secure copy command
  • file.txt — file you want to copy
  • root — username used to log onto CentOS machine
  • 1.1.1.1 — IP address of CentOS machine. Needless to say your Windows machine and the CentOS machine have to be able to communicate with one another
  • :/opt — This is the directory with which you save the file to, I generally save everything to the /opt directory
  • Don’t forget the @ between the username and IP Address and the : between the IP Address and directory you are saving the file to

If you need a key to login into the server, enter the following;

scp key.pem file.txt [email protected]:/opt

For handiness sake I just copy the file I want to copy across to the key file directory, that way you know everything will run smoothly

answered Mar 20, 2014 at 17:15

Dan's user avatar

DanDan

1951 silver badge7 bronze badges

to copy a file from windows to linux write:

scp -i privatekey pathFileOnWindows user@publicIp:pathDirectoryLinux 

(the colon : is important!)

Example:

//I am located here in my console

C:\Users\oscar>

//I’m executing the next command

scp -i C:\Users\oscar\Documents\llaves\ubuntu.pem C:\Users\oscar\Documents\index.html [email protected]:~/

You can puth the full path or location in the path where the file is located. ~/ means the home directory of the user ubuntu

Jenny D's user avatar

Jenny D

27.9k21 gold badges75 silver badges114 bronze badges

answered Mar 19, 2019 at 3:47

Oscar Javier Gómez Sánchez's user avatar

1

I would highly recommend to use WinSCP if you’re a Windows user. It has a good intuitive interface and gets the job done easily and with no pain.

Download link

enter image description here

answered Oct 1, 2015 at 19:52

Andrei's user avatar

AndreiAndrei

1611 silver badge3 bronze badges

If you are on the remote machine:

scp user@hostname:D:\text.txt user@hostname:/etc/var/test/test.txt

If you are currently on Windows machine:

winscp D:\text.txt user@hostname:/etc/var/test/test.txt

henrycarteruk's user avatar

answered Mar 14, 2014 at 10:56

pulsarjune's user avatar

pscp with -pw exposes my password, which I don’t like. The below answer works just like me using scp on linux -> linux.

pscp -scp C:\Windows\foo.txt [email protected]:/foo/bar

answered Aug 23, 2019 at 22:06

lobi's user avatar

lobilobi

1,0932 gold badges15 silver badges30 bronze badges

First you have to install any ssh client (OpenSSH) which support command line interface for your windows machine:

And add its path to windows Variable:

My Windows System output like below:

enter image description here

Then you will able to execute the same commands on your windows machine

You can copy also complete directory by executing:

scp -r path/to/dir_name/* user@remote-ip:/path/to/destination_dir

To Copy Single File:

scp -r path/to/file_name.zip user@remote-ip:/path/to/destination_dir/

Replace the file extension with your own file.

Jeter-work's user avatar

answered Mar 1, 2016 at 14:44

Ramesh Chand's user avatar

WinSCP is definitely an useful utility, especially if you want a graphic interface. But if you’re looking for a command line alternative without having to deal with installing cygwin, there’s also pscp which is part of the PuTTY collection of tools.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

answered Oct 1, 2015 at 21:25

p_q's user avatar

if you are using windows and want to copy to the linux server then install the WINSCP and just use the drag and drop

answered Oct 15, 2015 at 9:51

aryan's user avatar

OpenSSH is available for PowerShell since 2019. Instructions for installation are available from Microsoft’s Docs site. Instructions for use of OpenSSH utilities are available on OpenSSH project site.

Basically, once you install the OpenSSH suite, scp will work as you are accustomed.

scp user@source:path/to/source/file user@destination:path/to/target/file

where source and destination are hostnames or IP addresses and a path and filename without a host name/address will be treated as local.

answered Apr 5, 2021 at 14:20

Jeter-work's user avatar

Jeter-workJeter-work

8454 silver badges15 bronze badges

SCP <path of the file along with filename and extension> <name of vm>@<ip address>:<path where file needs to be copied>

answered Dec 19, 2022 at 7:49

Aditya Fargade's user avatar

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

How to get a file from my path d:/test.txt and copy it to /etc/var/test/test.txt?

I’ve tried this:

scp d:/test.txt /etc/var/test/test.txt

but that didn’t work.

How do I set the hard disk from where I copy my files?

clabacchio's user avatar

asked Mar 14, 2014 at 10:30

user3414354's user avatar

1

Umm, if you’re using cygwin you want that command to look like

scp /cygdrive/d/test.txt <linux ip>:/etc/var/test/test.txt

Or you can use WinSCP, you’ll probably find that simpler.

answered Mar 14, 2014 at 10:47

quadruplebucky's user avatar

The best way to copy files from Windows to Linux using the command line is through pscp. It is very easy and secure. For pscp to work on your windows machine, you need it add its executable to your systems path. Once it is done, you can use the following format to copy the file.

pscp -pw password D:\test.txt [email protected]:/etc/var/test/test.txt

You can refer the following blog post for more information on pscp setup.

http://comtechies.com/2016/02/copy-files-between-windows-and-linux.html

answered Feb 25, 2016 at 10:13

Bibin Wilson's user avatar

2

Assuming you are on Windows, best way is to download and install cygwin. Get the path to the binary folder and add it to the system path. You can now run Linux commands on your command line.

Open the command prompt and go to the directory where your file is that you want to copy. Run the following command;

scp file.txt [email protected]:/opt/
  • scp — secure copy command
  • file.txt — file you want to copy
  • root — username used to log onto CentOS machine
  • 1.1.1.1 — IP address of CentOS machine. Needless to say your Windows machine and the CentOS machine have to be able to communicate with one another
  • :/opt — This is the directory with which you save the file to, I generally save everything to the /opt directory
  • Don’t forget the @ between the username and IP Address and the : between the IP Address and directory you are saving the file to

If you need a key to login into the server, enter the following;

scp key.pem file.txt [email protected]:/opt

For handiness sake I just copy the file I want to copy across to the key file directory, that way you know everything will run smoothly

answered Mar 20, 2014 at 17:15

Dan's user avatar

DanDan

1951 silver badge7 bronze badges

to copy a file from windows to linux write:

scp -i privatekey pathFileOnWindows user@publicIp:pathDirectoryLinux 

(the colon : is important!)

Example:

//I am located here in my console

C:\Users\oscar>

//I’m executing the next command

scp -i C:\Users\oscar\Documents\llaves\ubuntu.pem C:\Users\oscar\Documents\index.html [email protected]:~/

You can puth the full path or location in the path where the file is located. ~/ means the home directory of the user ubuntu

Jenny D's user avatar

Jenny D

27.9k21 gold badges75 silver badges114 bronze badges

answered Mar 19, 2019 at 3:47

Oscar Javier Gómez Sánchez's user avatar

1

I would highly recommend to use WinSCP if you’re a Windows user. It has a good intuitive interface and gets the job done easily and with no pain.

Download link

enter image description here

answered Oct 1, 2015 at 19:52

Andrei's user avatar

AndreiAndrei

1611 silver badge3 bronze badges

If you are on the remote machine:

scp user@hostname:D:\text.txt user@hostname:/etc/var/test/test.txt

If you are currently on Windows machine:

winscp D:\text.txt user@hostname:/etc/var/test/test.txt

henrycarteruk's user avatar

answered Mar 14, 2014 at 10:56

pulsarjune's user avatar

pscp with -pw exposes my password, which I don’t like. The below answer works just like me using scp on linux -> linux.

pscp -scp C:\Windows\foo.txt [email protected]:/foo/bar

answered Aug 23, 2019 at 22:06

lobi's user avatar

lobilobi

1,0932 gold badges15 silver badges30 bronze badges

First you have to install any ssh client (OpenSSH) which support command line interface for your windows machine:

And add its path to windows Variable:

My Windows System output like below:

enter image description here

Then you will able to execute the same commands on your windows machine

You can copy also complete directory by executing:

scp -r path/to/dir_name/* user@remote-ip:/path/to/destination_dir

To Copy Single File:

scp -r path/to/file_name.zip user@remote-ip:/path/to/destination_dir/

Replace the file extension with your own file.

Jeter-work's user avatar

answered Mar 1, 2016 at 14:44

Ramesh Chand's user avatar

WinSCP is definitely an useful utility, especially if you want a graphic interface. But if you’re looking for a command line alternative without having to deal with installing cygwin, there’s also pscp which is part of the PuTTY collection of tools.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

answered Oct 1, 2015 at 21:25

p_q's user avatar

if you are using windows and want to copy to the linux server then install the WINSCP and just use the drag and drop

answered Oct 15, 2015 at 9:51

aryan's user avatar

OpenSSH is available for PowerShell since 2019. Instructions for installation are available from Microsoft’s Docs site. Instructions for use of OpenSSH utilities are available on OpenSSH project site.

Basically, once you install the OpenSSH suite, scp will work as you are accustomed.

scp user@source:path/to/source/file user@destination:path/to/target/file

where source and destination are hostnames or IP addresses and a path and filename without a host name/address will be treated as local.

answered Apr 5, 2021 at 14:20

Jeter-work's user avatar

Jeter-workJeter-work

8454 silver badges15 bronze badges

SCP <path of the file along with filename and extension> <name of vm>@<ip address>:<path where file needs to be copied>

answered Dec 19, 2022 at 7:49

Aditya Fargade's user avatar

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Secure data transfer via SCP

In the last article I showed you how to transfer data to a Ubuntu system via FTP. Nowadays FTP is not secure enough for internet use. Therefore I will show you SCP today. SCP is based on the SSH protocol. Therefore you need a user who can also access the server via SSH. As with SSH, you can use SSH keys to establish SCP connections. How to create SSH keys and store them on your server is shown in this article. 
Since Linux servers can also be managed from a Windows client, I will also show you the free program WinSCP in the course of this article, with which you can also transfer data from Windows to Linux servers via SCP.

Prepare Server

Since SCP or SSH as a client is a fixed part of every Linux distribution, you don’t need any further preparation on the client side. On the server side, depending on the distribution, you may need to install the SSH server service.
As before any installation, you should update your server to the latest version. For operating systems based on Debian (such as Ubuntu or Kubuntu), use the following command:

Copyapt -y update && apt -y upgrade && apt -y dist-upgrade

For CentOS or Red Hat or similar distributions YUM is used as package manager. Therefore, the command is as follows:

Copyyum update

To update your Fedora system, use the following command.

Copydnf update && dnf upgrade

Then start the installation with the following command:

Debian / Ubuntu

Copyapt -y install openssh-server

CentOS / RHEL

Copyyum install openssh-server

Fedora

Copydnf install openssh-server

Establishing a SSH connection

To test if the setup was successful, connect to your server via SSH. Open a terminal from your Linux or Apple client and execute the following command:

Copyssh <username>@<IPorDomainofServer>

Example:

Copyssh root@10.10.0.12

If you are using an SSH key, enter the password for your key now. Otherwise, the password for the user on the remote computer must be specified.

If everything is set up, the console of the remote computer should now be visible. If not, check your firewall settings. SSH requires port 22/tcp. You can also check the config of the SSH server and make sure that your user has the appropriate permissions.

Once you have successfully established the connection, you can close it again. Simply enter the command exit.

Copyexit

Transfer a file via SCP

For testing purposes, it is best to create a test file.

Copytouch /test.file

To transfer the file test.file to the other server use the following command:

Copyscp /path/to/file <benutzername>@<IPorDomainofServer>:/Path/to/destionationfolder/

Example:

Copyscp /test.file root@10.10.0.12:/root/secret/test.file

The file is now transferred to /root/secret on the server with IP 10.10.0.12.

If you want to download a file from a remote computer, you can also use SCP. The structure of the command has to be reversed.

Copyscp <username>@<IPorDomainofServer>:/Path/to/file/destination/path

Example:

Copyscp root@10.10.0.12:/root/secret/test.file /root/lokalsecrets/test.file

Make sure that the directories already exist.

You can also use SCP to transfer files from one server to another, from your client.

The syntax will look like this.

Copyscp <username>@<IPorDomainofServer>:/path/to/file <username>@<IPorDomainofServer>:/Path/to/destination

Example:

Copyscp root@10.10.0.12:/test.datei root@10.10.0.13/root/secret/test.file

If you use Windows 10 as client (from version 16.07) you can install the Linux subsystem and get a Ubuntu Bash including APT. With this you can use the syntax already shown.

Right-click “Start”, then on “Programs and Features” or for version 1703 “Apps and Features” and then on “Programs and Features”, then on “Activate or deactivate Windows features”. In the now open window, look for “Windows subsystem for Linux (beta)”. Afterwards the developer mode must be activated under Start -> Settings -> Update and security -> For developers. After the installation run cmd and type the command bash.

bash

Then confirm the installation with Y and type in a user name and password after a short wait.

If you are using an older version of Windows, you can take a look at the WinSCP program. You can find the current release here.

The setup of the tool is quite simple. Select Total Commander mode during installation. So on the left side of the window you will see your Local Folder Structure and on the right side the one of the server you have connected to. Files can be moved back and forth via Drag ‘n Drop and renamed, executed or deleted with a right click.

Conclusion

SCP is fairly quick to learn and reliably transmits even large amounts of data securely over the Internet. SCP is unfortunately very Linux-heavy – that means – Windows as client is no problem, but as soon as you use Windows as server, it becomes very difficult. As an alternative you can use WebDAV for example. I’ll show you how this works in this article. So if you work with different operating systems, you should take a look at both techniques.

В статье мы расскажем, как копировать файлы в 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 docs\file name” root@123.123.123.123:/home

Помогла ли вам статья?

Спасибо за оценку. Рады помочь 😊


 👍

I see this post is very old, but in my search for an answer to this very question, I was unable to unearth a solution from the vast internet super highway. I, therefore, hope I can contribute and help someone as they too find themselves stumbling for an answer. This simple, natural question does not seem to be documented anywhere.

On Windows 10 Pro connecting to Windows 10 Pro, both running OpenSSH (Windows version 7.7p1, LibreSSL 2.6.5), I was able to find a solution by trial and error. Though surprisingly simple, it took a while. I found the required syntax to be

BY EXAMPLE INSTEAD OF MORE OBSCURE AND INCOMPLETE TEMPLATES:

Transferring securely from a remote system to your local system:

scp user@remotehost:\D\mySrcCode\ProjectFooBar\somefile.cpp C:\myRepo\ProjectFooBar

or going the other way around:

scp C:\myRepo\ProjectFooBar\somefile.cpp user@remotehost:\D\mySrcCode\ProjectFooBar

I also found that if spaces are in the path, the quotations should begin following the remote host name:

scp user@remotehost:"\D\My Long Folder Name\somefile.cpp" C:\myRepo\SimplerNamerBro

Also, for your particular case, I echo what Cornel says:

On Windows, use backslash, at least at conventional command console.

Kind Regards.
RocketCityElectromagnetics

  • Scarface the world is yours fix для windows 10
  • Scangear mf невозможно установить связь со сканером windows 10
  • Scp toolkit driver installer windows 10
  • Screen sketch windows 10 что это
  • Scanning and repairing drive d 100 complete windows 10