Transfer file from windows to linux ssh

I am using putty to connect to a linux computer using ssh. I am on a local windows machine that has a file. I want to transfer a file from my windows machine to the linux machine. How could I do th...

I am using putty to connect to a linux computer using ssh. I am on a local windows machine that has a file. I want to transfer a file from my windows machine to the linux machine. How could I do this in command line without filezilla?

asked Apr 21, 2016 at 18:19

BishopSankey's user avatar

2

If ftp server is running in your Linux box then you can transfer files with filezilla (since it is ftp client). If that is not the case then download WinSCP a gui software like filezilla but uses SSH to transfer files.

answered Apr 21, 2016 at 18:25

kakurala's user avatar

kakuralakakurala

8146 silver badges15 bronze badges

If you are already on windows why not use GUI based clients? WinSCP is a good free client for transfers over SSH. It can transfer multiple files and also has auto resume facility.

answered Apr 21, 2016 at 18:27

Mrinal's user avatar

MrinalMrinal

3661 gold badge4 silver badges12 bronze badges

Using Putty’s PSCP command (which you can get from here) you can copy the file to your Linux computer by doing:

pscp.exe file_to_copy username@server_name:/path/destination_file_name

answered Apr 21, 2016 at 18:29

brandonhuddle's user avatar

The putty equivalent to scp is pscp. Get it where you got putty

scp is the ssh way to copy files to and from something running a ssh server. So you could send your file from the windows machine to Linux on the windows command line

answered Apr 21, 2016 at 18:23

infixed's user avatar

infixedinfixed

1,1257 silver badges14 bronze badges

We can do that using winscp. The command will be:

From command promopt:

scp «C:files*.*» username@linuxserver:/home/files/

answered Apr 29, 2020 at 3:26

Robi's user avatar

RobiRobi

731 silver badge7 bronze badges

Use the PSCP tool from the putty download page:

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

PSCP is the putty version of scp which is a cp (copy) over ssh command.

PSCP needs to be installed on your windows computer (just downloaded, really, there is no install process. In the Packaged Files section, pscp.exe is already included). Nothing needs to be installed on the school’s servers. PSCP and scp both use ssh to connect.

To answer the usage question from the comments:

To upload from your computer to a remote server:

c:pscp c:somepathtoafile.txt user@remote:homeusersomepath

This will upload the file file.txt to the specified directory on the server.
If the final part of the destination path is NOT a directory, it will be the new file name. You could also do this to upload the file with a different name:

c:pscp c:somepathtoafile.txt user@remote:homeusersomepathnewname.txt

To download a file from a remote server to your computer:

c:pscp user@remote:homeusersomefile.txt c:somepathtoa

or

c:pscp user@remote:homeusersomefile.txt c:somepathtoanewfile.txt

or

c:pscp user@remote:homeusersomefile.txt .

With a lone dot at the end there. This will download the specified file to the current directory.

Since the comment is too far down, I should also point out here that WinSCP exists providing a GUI for all this, if that’s of interest: http://winscp.net/eng/download.php

Copying data from a Windows PC to Linux—or in the other direction—can seem intimidating at first. After all, it’s something that seems like it should be simple but turns out to be difficult.

In truth, sharing files from Windows to Linux is easy, but only if you know how to do it. Ready to find out? Here’s everything you need to know about how to transfer files from Windows to Linux and back again.

4 Ways to Transfer Files From Windows to Linux

If you want to move data between Windows and Linux operating systems, it’s easier than you think. We’ve compiled four ways for you to do this:

  1. Securely copy files via SSH
  2. Windows to Linux file transfer with FTP
  3. Share data using sync software
  4. Use shared folders in your Linux virtual machine

With each of these methods, you’ll be able to easily (and, in some cases, effortlessly) carry out Linux to Windows or Windows to Linux file transfer.

Let’s look at them in turn and find out which one suits you best.

1. Copy Files Between Windows and Linux via SSH

With SSH enabled on your Linux device, you can send data via the command line from one computer to another. For this to work, however, you will need to set up an SSH server on your Linux machine.

Start by opening a terminal and updating and upgrading the OS.

 sudo apt update
sudo apt upgrade

Once complete, install the SSH server. The OpenSSH server is a good option.

 sudo apt install openssh-server 

Wait while it installs. To check at any time if the OpenSSH server is running, use:

 sudo service ssh status 

To transfer data from Windows, use an SSH client like PuTTY. This needs the PSCP (secure copy client) tool to download to your Windows system to run alongside PuTTY. Find both on the PuTTY downloads page.

Download: PuTTY

Note that while PuTTY will need installing, PSCP won’t. Instead, save the downloaded pscp.exe file in the root of the Windows C: drive or else set it up as an environment variable. You’ll also need to confirm the IP address of the Linux device. Check in the Linux terminal with:

 hostname -I 

With a connection established, you can transfer a file from Windows to Linux like this:

 c:pscp c:somepathtoafile.txt user@remoteIP:homeusersomepathnewname.txt 

You’ll be prompted for your password for the Linux computer before the transfer commences.

Want to copy files from Linux to Windows in the same SSH session? This command will download the specified file to the current directory:

 c:pscp user@remoteIP:homeusersomefile.txt . 

Note the lone period at the end, which you must include, or the transfer will not work.

2. How to Transfer Files From Linux to Windows Using FTP

You can also use a file transfer protocol (FTP) application with SSH support. Transferring files via SFTP in a mouse-driven user interface is arguably easier than relying on typed commands.

Again, an SSH server must be running on the Linux machine before you start. You should also ensure you have installed an FTP app on Windows, like FileZilla, which has SFTP support.

Download: FileZilla

To use this method, run FileZilla, then:

  1. Open File > Site Manager
  2. Create a New Site
  3. Set the Protocol to SFTP
  4. Add the target IP address in Host
  5. Specify a username and password
  6. Set the Logon Type to Normal
  7. Click Connect when ready
Share files between Linux and Windows using FTP

You can then use the FTP app to move files from Windows to Linux and back using drag and drop.

Another option you should consider is a file-syncing program. These are typically cross-platform and use an encrypted key to manage the connection between devices.

All you need to do is install the app, nominate a sync folder, then create the key. Set this up on the second PC, and your data will then sync. Two good options are available for this:

  1. Resilio Sync: Formerly known as BitTorrent Sync, Resilio is available on almost any platform you can think of. There is a paid version, but the free option is enough for syncing two devices
  2. Syncthing: For Linux, Windows, macOS, and Android, this Resilio Sync alternative offers a similar feature without the paid component

4. How to Transfer Files From Windows to a Linux Virtual Machine

Instead of running a separate PC, it’s common to run Linux or Windows in a virtual machine (VM). But is there a way to transfer files between Windows and Linux when one is installed in a VM?

Fortunately, yes. With VirtualBox, you can create a virtual shared directory for data syncing.

If you’re running Windows in a VM on Linux (or vice versa), VirtualBox is already set up for sharing. Ensure you have the Guest Additions installed on your virtual machine before proceeding.

In the VirtualBox manager, select the VM, then:

  1. Choose Start > Headless Start (or with the VM running, Devices > Shared Folders)
    Enable a headless start for your VM
  2. Once running, right-click the VM and select Settings > Shared Folders
  3. Select Machine Folders
  4. Click the + symbol on the right (or right-click and select Add Shared Folder)
  5. Browse the Folder Path and find the directory you want to use
  6. Set a name (if necessary), then OK
    Share files between Windows and Linux in a virtual machine
  7. Use the Auto-mount checkbox to ensure the share is available whenever the VM runs
  8. Click OK again to confirm and exit

When you reboot the VM, the share will be ready to swap data between the host PC and the guest operating system.

There is another option for sharing files between Windows and Linux PCs. However, creating a shared file on one or both systems and then accessing it across a network is unreliable at best.

Sharing Files Between Windows and Linux Is Easy

Whether you’re new to Linux or you find Windows unfamiliar, sharing data between them is easier than you think. Now that you know how to transfer files from Windows to Linux and vice versa, we’d recommend you try all the methods we’ve mentioned above and work out which one you’re most comfortable with.

If you’re syncing data to Linux, there’s a good chance you’re switching from Windows. Don’t worry—it’s easier than you think.

В статье мы расскажем, как передать файлы через SSH на разных операционных системах — Windows и Linux.

  1. Что нужно для подключения
  2. Как скопировать файл через SSH на Linux
    • Как отправить файл по SSH с локального компьютера на сервер
    • Как скачать файлы с удаленного сервера на компьютер
  3. Как скопировать файлы по SSH на Windows
    • Как загрузить файл с компьютера на сервер
    • Как скачать файл через SSH на локальный компьютер

Для подключения к серверу вам потребуются:

  • IP-адрес или имя сервера,
  • логин пользователя (в том числе root),
  • пароль пользователя,
  • порт.

Чаще всего копирование файлов через SSH делают с помощью двух мини-программ:

  1. scp (Secure Copy) — утилита для Linux. Она позволяет безопасно передать или скачать файл по протоколу SSH. Программа scp входит в комплект OpenSSH и не требует установки.
  2. pscp.exe — это утилита для Windows. Она используется по тому же назначению, что и scp: подключение к серверу по SSH и работа с файлами. Эта мини-программа входит в состав PuTTY: ее можно скачать на официальном сайте. Процедура настройки SSH-клиента описана в нашей статье.

Важно: если загружаемый файл существует на целевом хосте, он перезапишется.

Работа через SSH предполагает использование консольных команд. Наиболее популярные из них вы можете найти в статье.

Как скопировать файл через SSH на Linux

Копирование файлов по SSH на Linux можно сделать с помощью scp. Эта утилита позволяет:

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

Команда scp имеет следующий синтаксис:

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

Как отправить файл по SSH с локального компьютера на сервер

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

scp /home/test.doc username@servername:/directory

Где:

  • /home/test.doc — путь к файлу на локальном компьютере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory — директория на сервере, в которую нужно загрузить файл.

Готово, вы загрузили файл на сервер.

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

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

scp username@servername:/directory/test.doc /home

Где:

  • /directory/test.doc — путь к файлу на сервере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • home — папка на компьютере, в которую нужно загрузить файл.

Готово, вы скачали файл на компьютер.

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

Копирование через SSH на ОС Windows выполняется с помощью утилиты pscp.exe из набора PuTTY.

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

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

pscp C:/documents/test.doc username@servername:/directory

Где:

  • /documents/test.doc — путь к файлу на локальном компьютере;
  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory — директория на сервере, в которую нужно загрузить файл.

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

pscp “C:/documents/test 1.doc” username@servername:/directory

Готово, вы загрузили файл на сервер.

Как скачать файл через SSH на локальный компьютер

Чтобы загрузить файл:

  1. Подключитесь к серверу по SSH.
  2. Выполните команду:

pscp username@servername:/directory/test.doc C:/documents

Где:

  • username — имя SSH-пользователя;
  • servername — имя сервера или его IP-адрес;
  • directory/test.doc — путь к файлу на сервере;
  • /documents — директория на локальном компьютере, в которую нужно загрузить файл.

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

pscp username@servername:”/directory/test 1.doc” C:/documents

Готово, вы скачали файл на компьютер.

В статье мы расскажем, как копировать файлы в 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

Понравилась статья? Поделить с друзьями:
  • Transcriber pro скачать бесплатно на русском языке для windows
  • Transmission remote gui windows 10 скачать
  • Transmission remote gui windows 10 настройка
  • Transcodedwallpaper jpg скачать для windows 7
  • Transmac как записать образ на флешку windows