Scp remote to remote windows

SCP from Remote Server to Windows Local Machine

I would like to copy files from a remote Unix machine to a local Windows machine. The remote machine requires a secure connection, and therefore the default Windows tools, such as FTP, don’t work. I can run ssh on the local machine to log into the remote machine, but I am not able to run anything to copy the remote files to the local machine, since the local machine doesn’t have scp . Is there a way to copy them while ssh ed into the remote machine? For example, by setting up a pipe to receive the contents of the remote file and save it onto the local machine.

3 Answers 3

WinSCP is a graphical file transfer utility for Windows that supports both scp and (by default) sftp, in addition to other file transfer protocols.

If you install PuTTY that includes a command-line pscp utility, which is PuTTY’s equivalent of scp . Documentation on how to use pscp is here.

If you have python on your windows machine, you can try this:

If you do not have python, simpler approach is to install putty Scp

Not the answer you’re looking for? Browse other questions tagged ssh scp file-copy or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Copying a local file from Windows to a remote server using scp [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 1 year ago .

So, I’m attempting to simply transfer folder of files from my local computer to a server via ssh and scp. After sudoing I’m using the command as follows:

I get the error:

ssh: C: Name or service not known

I’m guessing its my syntax for c:/desktop etc. Any ideas?

BTW I’m using putty + Windows 7.

7 Answers 7

If your drive letter is C, you should be able to use

scp -r \desktop\myfolder\deployments\ user@host:/path/to/whereyouwant/thefile

without drive letter and backslashes instead of forward slashes.

You are using putty, so you can use pscp. It is better adapted to Windows.

-r ./localdir user@host:»D:\remotedir» – serigado Jun 11 ’20 at 16:16

Drive letters can be used in the target like

where c is the drive letter. It’s treated like a directory.

Maybe this works on the source, too.

On windows you can use a graphic interface of scp using winSCP. A nice free software that implements SFTP protocol.

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.

Читайте также:  Amd драйвера для windows 10 pro

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:

or going the other way around:

I also found that if spaces are in the path, the quotations should begin following the remote host name:

Also, for your particular case, I echo what Cornel says:

On Windows, use backslash, at least at conventional command console.

Use scp to transfer a file from local directory X to remote directory Y

I took a look around at other questions here and at various «scp usage» tutorials on Internet, but I can’t sort out what’s wrong.

I’m using Linux Mint and I’m trying to figure out how scp works.

I’ve a file file.ext (on my computer) in directory /home/name/dir/

I connect to a remote machine using ssh, like:

it asks me the password and the shell displays:

now, If I issue the command (before I ran ssh I was in the local directory /home/name/dir ):

Same result if instead of file.ext I write the complete path

Also, the server admin told me that I shall upload the file to my remote home directory (instead of root), like:

but when I do it and press «Enter» nothing happens, as If the shell was waiting for further input.

Summary of my problems:

  • cp: no such file or directory
  • shell «stuck» on

8 Answers 8

You need to run the scp command from the local machine, not on the remote. You don’t need the ssh at all:

You also don’t need the -r :

If you are already logged into the remote machine and want to copy from your local, you need to make sure that your local machine is accessible via the internet and has ssh set up. I don’t think this is what you are after but if it is, just run this from the remote:

I provide two methods of up/down load file between remote and local machine(I use Mac air):

In this case, I want to up/down 11.jpeg between local and remote:

Copy files on service to local dir: You must be in local bash terminal to conduct this command, not when you are in ssh!

copy files in local dir to remote service : also you must be in local bash terminal

To achieve the same intention when you are logging in the SSH, you must first set “System Preferences>sharing>remote log in>all users(I am not sure if you must set for «all users», but it works in this situation)” the Mac will tell you»To log in to this computer remotely, type:

This command above is for downloading file from remote to local when you are logging into ssh, Just change the two path when you want to upload file .

– maizer Aug 14 ’18 at 19:57

Use the scp command

If you want to transfer a folder, just zip it first, we can unzip it later on.

From your computer, run this:

Here, root is your account, and 10.145.198.100 is the remote server’s IP address. We’re going to copy the_file to

/ folder in the remote.

Unzip file:

If you’re running this scp command on the remote machine, it is looking for file.ext as a «local» file, i.e. on the remote machine.

To copy a file from the remote machine to the local one, use scp -P 2222 username@domain:dir/file.ext localdir (assuming that file.ext is in

/dir on the remote computer, as in your example). If you run scp on the remote machine, reverse «local» and «remote».

Just a small contribution, maybe it can help beginners like me: the path to the the remote directory should be written like this: username@domain:

What I want to highlight here is that we should always add that :

Solution to copy files from Linux client to Linux server

Check if sshd is running on your server using: ps aux | grep sshd

If not, install OpenSSH using sudo apt-get install openssh-server openssh-client https://www.tecmint.com/install-openssh-server-in-linux/

Restart your server and verify that sshd is running using ps aux | grep sshd

If you need you can configure your /etc/ssh/sshd_config file, but it’s not necessary for simple configurations

verify that the ports are open using netcat : nc -v -z 127.0.0.1 22

To copy files from a Linux client to a Linux client use scp as follows scp

To verify that file has been copied use ssh username@10.22.33.45 and provide your password.

Solution to copy files from Linux client to Windows

There are multiple clients for running SSH servers on Windows, such as:

Install one of the above servers and make sure that port 22 is open using

Comparisons of these servers:

Bitvise SSH server

Provides almost close to native cmd prompt, powershell prompt, autocompletion

Provides additional capabilities for customization, if you need advanced usage

User customization for simple needs is 0. I got started on it within 2 minsute, after having spent a lot of time trying to get MobaSSH and OpenSSH to work.

To copy files using scp use: scp

Free for personal use, $99 for professional use. Because of so many features and great integration, the price is well worth the money.

provides a Linux shell on Windows where simple Linux commands such as ls , cp , find , etc., work, similar to MINGW64

you can access cmd and powershell directly by typing cmd or powershell

Unicode support is poor. Encoding is not correct. For example if you try to start Python interpretor, it will crash. You will need to change the encoding manually using (https://stackoverflow.com/a/12834315/4752883): chcp 65001 set PYTHONIOENCONDING=utf-8 and then startup Python prompt

The great thing about MobaSSH is that it has a very simple user-interface, and scp and ssh and integrated well. So will work for simple use cases

To copy files from a Linux client to a Windows server running MobaSSH : use scp

/filename.md username@10.33.44.45:/cygdrive/c/Users/username/filename.md This is because MobaSSH is based on Cygwin and its drives are mapped to the same way cygwin -s drives are mapped.

Use VMs from Microsoft with OpenSSHv6.7 installed from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/, OpenSSHv6.7 is already installed.

It’s very buggy, and you will need to heavily customize it.

Command completion doesn’t work

It will leave blank spaces when you are moving cursor on the terminal

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!

7 Answers 7

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.

How do I copy a folder from remote to local using scp?

How do I copy a folder from remote to local host using scp ?

I use ssh to log in my server.
Then, I would like to copy the remote folder foo to local /home/user/Desktop .

How do I achieve this?

11 Answers 11

By not including the trailing ‘/’ at the end of foo, you will copy the directory itself (including contents), rather than only the contents of the directory.

-r Recursively copy entire directories

To use full power of scp you need to go through next steps:

Then, for example if you have this

you’ll save yourself from password entry and simplify scp syntax like this:

More over, you will be able to use remote path-completion:

Update:

For enabling remote bash-completion you need to have bash-shell on both and hosts, and properly working bash-completion. For more information see related questions:

To copy all from Local Location to Remote Location (Upload)

To copy all from Remote Location to Local Location (Download)

Custom Port where xxxx is custom port number

Copy on current directory from Remote to Local

Help:

  1. -r Recursively copy all directories and files
  2. Always use full location from / , Get full location by pwd
  3. scp will replace all existing files
  4. hostname will be hostname or IP address
  5. if custom port is needed (besides port 22) use -P portnumber
  6. . (dot) — it means current working directory, So download/copy from server and paste here only.

Note: Sometimes the custom port will not work due to the port not being allowed in the firewall, so make sure that custom port is allowed in the firewall for incoming and outgoing connection

Читайте также:  Где хранятся резервные копии itunes для windows 10
Оцените статью