Copying a local file from Windows to a remote server using scp

WindowsSshCopySudoScp

Windows Problem Overview


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:

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

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.

Windows Solutions


Solution 1 - Windows

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.

Solution 2 - Windows

Drive letters can be used in the target like

scp some_file user@host:/c/temp

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

Maybe this works on the source, too.

Solution 3 - Windows

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

Solution 4 - Windows

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

Solution 5 - Windows

You can also try this:

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

Solution 6 - Windows

I have found it easiest to use a graphical interface on windows (I recommend http://mobaxterm.mobatek.net/">mobaXTerm</a> it has ssh, scp, ftp, remote desktop, and many more) but if you are set on command line I would recommend cd'ing into the directory with the source folder then
scp -r yourFolder username@server:/path/to/dir
the -r indicates recursive to be used on directories

Solution 7 - Windows

Drive letter can be used in the source like

scp /c/path/to/file.txt user@server:/dir1/file.txt

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHelloWorldView Question on Stackoverflow
Solution 1 - WindowsSerkan YilmazView Answer on Stackoverflow
Solution 2 - WindowsJasonView Answer on Stackoverflow
Solution 3 - WindowsjediView Answer on Stackoverflow
Solution 4 - WindowsCharlesView Answer on Stackoverflow
Solution 5 - WindowsAdityaView Answer on Stackoverflow
Solution 6 - Windowshehe3301View Answer on Stackoverflow
Solution 7 - WindowsIgor MukhinView Answer on Stackoverflow