Ssh scp from linux to windows

Windows 10 now has OpenSSH built in.
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Get an admin command prompt

Open PowerShell as an Administrator.

Check available versions

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

Install client

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

Install server

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Start server and enable at boot

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

Find your Windows IP address

ipconfig

On your remote (Linux) machine, find your IP address.

ifconfig

Create a public SSH key

ssh-keygen.exe

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.

cat C:\Users\YOU/.ssh/id_rsa.pub | ssh USER@REMOTE_IP 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

Do the same on your Linux machine (Note, ssh-copy-id does not work)

ssh-keygen # if needed
cat ~/.ssh/id_rsa.pub | ssh USER@WINDOWS_IP 'mkdir -p ~/.ssh && type con >> C:/Users/YOU/.ssh/authorized_keys'
  • 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

    • Open %programdata%\ssh\sshd_config

    • Add the following lines:

        Match User YOU
             AuthorizedKeysFile C:/Users/YOU/.ssh/authorized_keys
  • Reboot

Create a password on Windows if you don’t already have one

System Settings...Sign-in options

— 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

scp FILE WINDOWS_IP:C:/Users/YOU/Desktop

Windows 10 now has OpenSSH built in.
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Get an admin command prompt

Open PowerShell as an Administrator.

Check available versions

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

Install client

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

Install server

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Start server and enable at boot

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

Find your Windows IP address

ipconfig

On your remote (Linux) machine, find your IP address.

ifconfig

Create a public SSH key

ssh-keygen.exe

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.

cat C:\Users\YOU/.ssh/id_rsa.pub | ssh USER@REMOTE_IP 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'

Do the same on your Linux machine (Note, ssh-copy-id does not work)

ssh-keygen # if needed
cat ~/.ssh/id_rsa.pub | ssh USER@WINDOWS_IP 'mkdir -p ~/.ssh && type con >> C:/Users/YOU/.ssh/authorized_keys'
  • 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

    • Open %programdata%\ssh\sshd_config

    • Add the following lines:

        Match User YOU
             AuthorizedKeysFile C:/Users/YOU/.ssh/authorized_keys
  • Reboot

Create a password on Windows if you don’t already have one

System Settings...Sign-in options

— 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

scp FILE WINDOWS_IP:C:/Users/YOU/Desktop

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,4923 gold badges38 silver badges50 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,4111 gold badge7 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:\Users\Name\Downloads

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

ifnotak's user avatar

ifnotak

4,1973 gold badges22 silver badges36 bronze badges

answered Jun 8, 2016 at 20:49

Hesham Eraqi's user avatar

Hesham EraqiHesham Eraqi

2,4524 gold badges23 silver badges45 bronze badges

4

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,5443 gold badges24 silver badges25 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:\dir1\dir2"

Wenfang Du's user avatar

Wenfang Du

9,02412 gold badges60 silver badges92 bronze badges

answered Jan 4, 2019 at 13:18

byteprom's user avatar

byteprombyteprom

5514 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

3451 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,9063 gold badges44 silver badges56 bronze badges

answered Apr 19, 2012 at 19:59

theglauber's user avatar

theglaubertheglauber

28.4k7 gold badges29 silver badges47 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.9k17 gold badges102 silver badges189 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 [email protected]:/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 [email protected]:/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

6061 gold badge8 silver badges21 bronze badges

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 [email protected]:/data/genetic_map/sample/P2_283/* \\Desktop-mojbd3n\d\cc_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-mojbd3n\d\genetic_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

1783 silver badges14 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/*.* [email protected]:/d/test/

Details:

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

serenesat's user avatar

serenesat

4,61110 gold badges37 silver badges53 bronze badges

answered Aug 28, 2015 at 12:47

Ramarajan Jothi's user avatar

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 [email protected]:/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

1,0571 gold badge10 silver badges21 bronze badges

Try this:

scp /home/ubuntu/myfile C:\users\Anshul\Desktop

Pang's user avatar

Pang

9,623146 gold badges81 silver badges122 bronze badges

answered Jan 12, 2013 at 2:50

Corey Burnett's user avatar

Corey BurnettCorey Burnett

7,31210 gold badges56 silver badges93 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

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.

Как копировать и передавать файлы по SSH

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

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

  • Ssgdio64 sys невозможно загрузить драйвер windows 11
  • Ssh client windows server 2016
  • Ssh rdp клиент для windows
  • Ssd windows обнаружила неполадки жесткого диска
  • Ssh client windows 10 скачать