- Copy Files Between Windows and Linux Using Command Line
- Copy File from Windows To Linux Using PSCP
- Copy File From Linux To Windows Using PSCP
- Copy File from Windows To Linux Using FTP GUI
- Conclusion
- Копирование файлов scp
- Что такое SCP?
- Копирование файлов scp
- Выводы
- How to SCP from Linux server to Windows client
- 9 Answers 9
- Get an admin command prompt
- Check available versions
- Install client
- Install server
- Start server and enable at boot
- Find your Windows IP address
- On your remote (Linux) machine, find your IP address.
- Create a public SSH key
- Copy public key from local (Windows) to remote (Linux) machine so you don’t have to type in a password all the time.
- Note that ssh-copy-id is not currently available on Windows.
- Do the same on your Linux machine (Note, ssh-copy-id does not work)
- Create a password on Windows if you don’t already have one
- Now you should be able to SSH or SCP from your Linux machine
- Копирование файлов через SSH
- Копирование файлов по SSH на Linux
- Как скопировать файл по SSH с локальной машины на удалённый сервер
- Как скопировать файлы с удалённого сервера на локальный компьютер
- Как скачать папку со всеми файлами и подпапками
- Как подключиться к серверу по нестандартному порту
- Как передать и скачать файлы по SSH на Windows
Copy Files Between Windows and Linux Using Command Line
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
- Using command line with pscp
- 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.
Step 2: copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:\Windows\System32 path.
Step 3: Open Windows PowerShell and use the following command to verify if pscp is accessible from the path.
You should see the following output.
Step 4: Use the following format to copy the single file from Windows to the Linux box.
Here is the explanation of the command.
- -pw for the password.
- Replace password with the Linux user password.
- C:\Users\Admin\Desktop\test.txt represents the path of the file that has to be copied to the Linux system.
- 192.168.33.10 is the IP of the Linux server.
- /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.
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.
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.
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.
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.
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.
Источник
Копирование файлов scp
Если у вас есть домашний сервер или сервер в интернете, то вам понадобится способ для безопасного перемещения файлов между машинами. Между локальными машинами мы могли бы просто переносить данные с помощью флешки, но на удаленный сервер нужно передавать данные только через сеть. Есть много способов реализации этой задачи.
В этой статье мы рассмотрим как выполняется копирование файлов с помощью утилиты scp (Secure Copy Command), а также что из себя представляет команда Linux scp. При передаче файлы шифруются, так что больше никто не сможет получить к ним доступ и самое интересное, что вам не нужно настраивать FTP или другое дополнительное программное обеспечение. Будет достаточно сервера SSH.
Что такое SCP?
Команда scp — это утилита, которая работает по протоколу SSH, а значит, все что вам нужно для передачи файла на компьютер, это чтобы на нем был запущен SSH сервер, а также вы должны знать логин и пароль для подключения к нему. С помощью команды scp вы можете не только перемещать файлы между локальной и удаленной системой, но и между двумя удаленными системами. Для этого тоже будет достаточно знать пароли от них. И в отличие от Rsync вам не нужно авторизоваться на одном из серверов.
Копирование файлов scp
Эта статья рассчитана в первую очередь на начинающих, поэтому я попытаюсь объяснять все как можно подробнее. Перед тем, как мы перейдем к практике, нужно рассмотреть общий синтаксис команды:
$ scp опции пользователь1@хост1 : файл пользователь2@хост2: файл
Опции утилиты больше касаются протокола SSH и настраивают общее ее поведение. Дальше следует адрес первого и второго файла. Каждый из них может быть расположен как на локальной, так и на удаленной машине. А теперь рассмотрим основные опции, которые могут нам понадобиться:
- -1 — использовать протокол SSH1;
- -2 — использовать протокол SSH2;
- -B — пакетный режим для передачи нескольких файлов;
- -C — включить сжатие;
- — l — установить ограничение скорости в кбит/сек;
- -o — задать нужную опцию SSH;
- -p — сохранять время модификации;
- -r — рекурсивное копирование директорий;
- -v — более подробный режим.
scp /home/sergiy/file root@losst.ru:/root/
В качестве пользователя нужно использовать любого пользователя, который есть на сервере. Вместо IP вы можете также домен сервера. Только необходимо, чтобы у выбранного пользователя были права записи в указанную папку.
С помощью опции -r вы можете скопировать на удаленную машину целый каталог. Команда будет выглядеть вот так:
scp -r /home/sergiy/photos root@losst.ru:/root/
Убедитесь, что у исходного каталога нет косой черты, а у каталога назначения она должна обязательно быть. Немного изменив синтаксис с косой чертой можно передать все файлы из каталога на удаленный сервер:
scp -r /home/sergiy/photos/* root@losst.ru:/root/
Если поменять местами локальный путь и сервер, то вы сможете копировать файлы scp c удаленного сервера на локальный компьютер:
scp root@losst.ru:/root/file /home/sergiy/
Таким же самым образом вы можете копирование файлов scp или папок с сервера:
scp -r root@losst.ru:/root/photos /home/sergiy/
Обратите внимание, что папка, в которую вы собираетесь копировать должна завершаться косой чертой, иначе папка, которую вы копируете запишется вместо той, в которую нужно скопировать.
Чтобы скачать файл scp из одного сервера на другой, просто необходимо указать данные аутентификации на каждом из них. Например, скопируем один файл:
scp root@losst.ru:/home/root/index.html root@losst.ru:/home/root/www/
Скопируем папку с того же удаленного сервера:
scp root@losst.ru:/root/photos root@losst.ru:/home/root/www/
Выводы
В этой статье мы рассмотрели как выполняется передача файлов scp, как это работает и что вы можете сделать с помощью этой утилиты. Как вы видите, перемещать файлы с одного сервера на другой очень просто. В Linux достаточно понять основы чтобы начать работать эффективнее! А команда scp один из таких инструментов.
Источник
How to SCP from Linux server to Windows client
I’m SSHing into a Linux machine using PuTTY and trying to copy a file down somewhere (anywhere) to my local machine. I figure SCP is the best candidate for the job but don’t really care, so long as the solution works!
I cd to the directory containing the file I want ( app.war ) and type the following:
I’ve tried both to no avail:
It got me thinking that perhaps SCP is a client/server tool and requires a client on my Windows machine, which isn’t there.
Am I just using the wrong syntax? Or am I way off-base? If so, what options do I have? Thanks in advance!
9 Answers 9
in order for you to copy files back to your Windows you need SSH daemon/service to be running on your Windows, it’s much easier to use this tool instead, it has an ability to import sessions from Putty, very plain forward client you’ll love it!
You are correct. SSHD is the SSH server services that runs on the host. It accepts connections from SSH clients (like PuTTy), SCP clients, and SFTP clients.
You can download pscp from the same website where PuTTY is hosted.
From the windows machine, you would execute a command similar to
pscp.exe someuser@somehost.com:/path/to/app.war c:\tmp
Get an admin command prompt
Check available versions
Install client
Install server
Start server and enable at boot
Find your Windows IP address
On your remote (Linux) machine, find your IP address.
Create a public SSH key
Copy public key from local (Windows) to remote (Linux) machine so you don’t have to type in a password all the time.
Note that ssh-copy-id is not currently available on Windows.
Do the same on your Linux machine (Note, ssh-copy-id does not work)
The method above did not work for me, so I ended up manually SCPing the public key over and pasting it into the C:/Users/YOU/.ssh/authorized_keys file.
That still did not work, so I had to modify the sshd_config file.
Open Notepad as Administrator
Add the following lines:
Create a password on Windows if you don’t already have one
— Note, you can still disable the Windows login screen by a) Setting the ‘Require sign-in’ option to never and b) Using the ‘netplwiz’ command and unticking the ‘Users must enter password. ‘ checkbox.
Now you should be able to SSH or SCP from your Linux machine
You can do this by using the Linux Ubuntu subsystem for Windows (you need to enable this as a Windows feature). Then you can use a Linux terminal client that runs on Windows by getting it from the Microsoft Store (e.g. Ubuntu 16.04 LTS). Then, if you have ssh security set up to remote into your Linux machine, you can scp from your local Windows Ubuntu terminal (when logged in as the username that you set for your Linux instance) something like this:
/ . enter RSA passphrase
The remote file will be copied into your local Ubuntu filesystem used by Windows e.g.
To SCP a file to a Windows machine, you need an SSH/SCP server on the Windows.
There’s no SSH/SCP support in Windows by default. You can install Microsoft build of OpenSSH for Windows (Releases and Downloads). It’s available as optional feature on Windows 10 version 1803 and newer. It can also be manually installed on older versions of Windows.
Though as you SSH into the Linux server from the Windows machine, you actually can download a file from the Linux server to the Windows server, instead of trying to upload the file from the Linux server to Windows server.
In you have an SSH access from Windows to Linux, you have an SCP access too (or even better an SFTP access).
Use any SCP/SFTP client available.
Another alternative is PuTTY toolset, which includes the pscp command-line tool with a syntax similar to the OpenSSH scp command. Also the latest versions of Windows 10 comes with OpenSSH scp built-in and it can be installed on older versions too.
Источник
Копирование файлов через SSH
В статье мы расскажем, как копировать файлы в 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».
Как скачать папку со всеми файлами и подпапками
Если вы хотите скачать папку со всеми файлами и подпапками, используйте ключ -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
Источник