How to SCP from linux server to Windows client

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!

WinSCP :: Free SFTP and FTP client for Windows


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 [email protected]:/path/to/app.war c:\tmp


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