Scp from windows to server

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

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

There are multiple methods of uploading files from Windows server to Linux server. It can be done both from the Windows command line and with applications with a graphical interface. Let’s take a look at «How to upload a file to Linux server from Windows».

How to safely upload file to Linux server from Windows?

To copy files between two servers, they must be on the same network. SCP (Secure Copy) and SFTP(Secure FTP) are used for installation. File transfer is encrypted and secure as SCP and SFTP use SSH. SCP(Secure Copy) and SFTP(Secure FTP) are used for upload. The applications we will give examples below are SSH clients.

Pre-requisites

  • The Windows is reachable to the Linux Server. If the Linux is on your VirtualBox then you can use Bridged Networking or NAT with Port Forwarding to be on the same network as Windows.
  • SSHD service MUST be in running state as the file transfer will happen over OpenSSH protocol. You may also choose to setup vsftpd to use dedicated FTP server for file transfer but that is optional.
  • Firewall on the Linux server must be accepting traffic on Port 22 (default SSHD port) or the port used by Linux server. Execute netstat -ntlp | grep ssh on the Linux server to get this information.

Method-1: Upload with SCP and PSCP using CLI CMD

Press the Windows key and type cmd and open the command line.

SCP command usage : scp example_file target_user@ip_address:/target_file_path

C:\Users\faruk\Downloads>scp Get_Started_With_Smallpdf.pdf foc@192.168.122.177:/tmp
foc@192.168.122.177's password:
Get_Started_With_Smallpdf.pdf 100% 68KB 67.8KB/s 00:00

The file is uploaded successfully with the SCP command.

PSCP command usage:    pscp example_file target_user@ip_address:/target_file_path

C:\Users\faruk\Documents>pscp sample.pdf foc@192.168.122.118:/tmp
foc@192.168.122.118's password:
sample.pdf | 2 kB | 3.0 kB/s | ETA: 00:00:00 | 100%

The sample.pdf file has been successfully uploaded to the target linux server.

ALSO READ: How to set SFTP umask in Linux? [100% Working]

Method-2: Using WinSCP

You can download winscp if it is not installed on your Windows server. It is a free software for download. File upload can be done with both SFTP and SCP in WinSCP.

Using SFTP Protocol

Fill the following fields:

  • File Protocol: SFTP (to perform file transfer securely)
  • Host Name: Linux server IP
  • Port Number: In most cases it is 22 but if you are using a different port number for OpenSSH then connect to Linux server and execute netstat -ntlp | grep ssh to get the port number used by SSHD process
  • User name: Provide the username from Linux server using which you want to connect
  • Password: Password of the respective user

Click on Login to continue.

[SOLVED] Upload file to Linux server from Windows

Windows (Left) and target Linux server (Right) directories are listed. You can change the destination directory of your source and destination accordingly on LEFT or RIGHT side. Next to upload the file you can just drag it to the destination location. Don’t worry it will NOT move the file and instead it will just copy the file to destination Linux server.

[SOLVED] Upload file to Linux server from Windows

The selected file has been successfully uploaded to the Linux server.

[SOLVED] Upload file to Linux server from Windows

Using SCP Protocol

You can also upload by choosing SCP as the protocol in WinSCP.

Fill the following fields:

  • File Protocol: SCP (to perform file transfer securely)
  • Host Name: Linux server IP
  • Port Number: In most cases it is 22 but if you are using a different port number for OpenSSH then connect to Linux server and execute netstat -ntlp | grep ssh to get the port number used by SSHD process
  • User name: Provide the username from Linux server using which you want to connect
  • Password: Password of the respective user

[SOLVED] Upload file to Linux server from Windows

Now you can change your source and destination directory in the WinScp. Next drag the files or directory from LEFT side to the RIGHT side for the upload.

ALSO READ: Linux copy directory and contents from remote to local & vice versa

[SOLVED] Upload file to Linux server from Windows

Uploading with SCP was completed successfully.

Method-3: Using Filezilla

FileZilla is another freely available software for windows which we use to upload files to Linux server. You can download FileZilla based on your Windows environment. Fill in the below details:

  • Host: Target Linux server IP
  • Port Number: In most cases it is 22 but if you are using a different port number for OpenSSH then connect to Linux server and execute netstat -ntlp | grep ssh to get the port number used by SSHD process
  • User name: Provide the username from Linux server using which you want to connect
  • Password: Password of the respective user

Then click the Quickconnect button:

[SOLVED] Upload file to Linux server from Windows

Windows server directories are listed on the left, and target Linux server directories are listed on the right. The file to be uploaded to the Linux server is selected from the left screen and right clicked. Then click Upload and the file is sent to the Linux server.

[SOLVED] Upload file to Linux server from Windows

You can also do the same by dragging the file to the right screen.  A notification is displayed when the file upload is complete.

[SOLVED] Upload file to Linux server from Windows

You can upload one or more files this way.

Summary

We have explained the most used methods to upload files from Windows to Linux server. You can use different methods by researching it yourself. Finally, you should pay attention to the fact that the user to copy should exist on the target server and the directory she is authorized should be selected as the target directory.  Otherwise, you will have access and authorization problems.

You can find the download link of the applications we used above below:

  • Download PSCP
  • Download WinSCP
  • Download Filezilla

References

stackoverflow.com — How to upload a file from Windows machine to Linux machine using command lines via PuTTy?

Can’t find what you’re searching for? Let us assist you.

Enter your query below, and we’ll provide instant results tailored to your needs.

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

.

В Windows 10 и Windows Server 2019 появился встроенный SSH клиент, который вы можете использовать для подключения к *Nix серверам, ESXi хостам и другим устройствам по защищенному протоколу, вместо Putty, MTPuTTY или других сторонних SSH клиентов. Встроенный SSH клиент Windows основан на порте OpenSSH и предустановлен в ОС, начиная с Windows 10 1809.

Содержание:

  • Установка клиента OpenSSH в Windows 10
  • Как использовать SSH клиенте в Windows 10?
  • SCP: копирование файлов из/в Windows через SSH

Установка клиента OpenSSH в Windows 10

Клиент OpenSSH входит в состав Features on Demand Windows 10 (как и RSAT). Клиент SSH установлен по умолчанию в Windows Server 2019 и Windows 10 1809 и более новых билдах.

Проверьте, что SSH клиент установлен:

Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Client*'

'OpenSSH.Client установка в windows 10

В нашем примере клиент OpenSSH установлен (статус: State: Installed).

Если SSH клиент отсутствует (State: Not Present), его можно установить:

  • С помощью команды PowerShell:
    Add-WindowsCapability -Online -Name OpenSSH.Client*
  • С помощью DISM:
    dism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0
  • Через Параметры -> Приложения -> Дополнительные возможности -> Добавить компонент. Найдите в списке Клиент OpenSSH и нажмите кнопку Установить.

клиент openssh установить компонент

]Бинарные файлы OpenSSH находятся в каталоге c:\windows\system32\OpenSSH\.

  • ssh.exe – это исполняемый файл клиента SSH;
  • scp.exe – утилита для копирования файлов в SSH сессии;
  • ssh-keygen.exe – утилита для генерации ключей аутентификации;
  • ssh-agent.exe – используется для управления ключами;
  • ssh-add.exe – добавление ключа в базу ssh-агента.

исполняемые файлы OpenSSH

Вы можете установить OpenSSH и в предыдущих версиях Windows – просто скачайте и установите Win32-OpenSSH с GitHub (есть пример в статье “Настройка SSH FTP в Windows”).

Как использовать SSH клиенте в Windows 10?

Чтобы запустить SSH клиент, запустите командную строку
PowerShell
или
cmd.exe
. Выведите доступные параметры и синтаксис утилиты ssh.exe, набрав команду:

ssh

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
destination [command]

параметры ssh клиента в windows

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

ssh username@host

Если SSH сервер запущен на нестандартном порту, отличном от TCP/22, можно указать номер порта:

ssh username@host -p port

Например, чтобы подключиться к Linux хосту с IP адресом 192.168.1.202 под root, выполните:

ssh [email protected]

При первом подключении появится запрос на добавление ключа хоста в доверенные, наберите yes -> Enter (при этом отпечаток ключа хоста добавляется в файл C:\Users\username\.ssh\known_hosts).

Затем появится запрос пароля указанной учетной записи, укажите пароль root, после чего должна открытся консоль удаленного Linux сервера (в моем примере на удаленном сервере установлен CentOS 8).

подключение из windows 10 в linux с помощью встроенного ssh клиента

С помощью SSH вы можете подключаться не только к *Nix подобным ОС, но и к Windows. В одной из предыдущих статей мы показали, как настроить OpenSSH сервер на Windows 10 и подключиться к нему с другого компьютера Windows с помощью SSH клиента.

Если вы используете SSH аутентификацию по RSA ключам (см. пример с настройкой SSH аутентификации по ключам в Windows), вы можете указать путь к файлу с закрытым ключом в клиенте SSH так:

ssh [email protected] -i "C:\Users\username\.ssh\id_rsa"

Также вы можете добавить ваш закрытый ключ в SSH-Agent. Сначала нужно включить службу ssh-agent и настроить ее автозапуск:

set-service ssh-agent StartupType ‘Automatic’
Start-Service ssh-agent

Добавим ваш закрытый ключ в базу ssh-agent:

ssh-add "C:\Users\username\.ssh\id_rsa"

Теперь вы можете подключиться к серверу по SSH без указания пути к RSA ключу, он будет использоваться автоматически. Пароль для подключения не запрашивается (если только вы не защитили ваш RSA ключ отдельным паролем):

ssh [email protected]

Еще несколько полезных аргументов SSH:

  • -C
    – сжимать трафик между клиентом и сервером (полезно на медленных и нестабильных подключениях);
  • -v
    – вывод подробной информации обо всех действия клиента ssh;
  • -R
    /
    -L
    – можно использовать для проброса портов через SSH туннель.

SCP: копирование файлов из/в Windows через SSH

С помощью утилиты scp.exe, которая входит в состав пакета клиента SSH, вы можете скопировать файл с вашего компьютера на SSH сервер:

scp.exe "E:\ISO\CentOS-8.1.1911-x86_64.iso" [email protected]:/home

scp.exe копирование файлов через ssh

Можно рекурсивно скопировать все содержимое каталога:

scp -r E:\ISO\ [email protected]:/home

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

scp.exe [email protected]:/home/CentOS-8.1.1911-x86_64.iso e:\tmp

Если вы настроите аутентификацию по RSA ключам, то при копировании файлов не будет появляться запрос на ввод пароля для подключения к SSH серверу. Это удобно, когда вам нужно настроить автоматическое копирование файлов по расписанию.

Итак, теперь вы можете прямо из Windows 10 подключаться к SSH серверам, копировать файлы с помощью scp без установки сторонних приложений и утилит.

  • Screen reader для windows 7
  • Sc2020 xerox driver windows 10
  • Scm msi скачать windows 10 скачать
  • Screen mirroring для пк скачать windows 10 скачать
  • Scanner for windows 10 download