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.

share|improve this question
2  
The standard path on windows/dos says to use \ backslash, so try C:\desktop\myfolder\deployments\ – Cornel Ghiban Jan 23 '12 at 17:31
up vote 23 down vote accepted

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.

share|improve this answer
    
scp -r root@31.222.168.64:/var/www/vhosts/mywork \test --- I added this code this is create a test folder in my server no in my local computer scp -r root@31.222.168.64:/var/www/vhosts/mywork D:\test ---gives error "ssh: Could not resolve hostname D: Name or service not known lost connection" – pTi Mar 26 '16 at 17:31
    
@pTi which scp are you using? If you are using Cygwin's scp, you can use the path as /cygdrive/d/test. To omit using /cygdrive you can run mount --change-cygdrive-prefix / so that the path would be /d/test instead. – Serkan Yılmaz Jun 8 '16 at 20:40

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.

share|improve this answer
4  
Thanks for this simple and working answer, not trying to make me use another software or whatever ! I was searching the web to find just that, nobody answers the question directly... – Benj Jul 2 '15 at 8:10
    
this does not work to get the files – Jorge Machado May 18 '17 at 6:02

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

share|improve this answer
    
Works great! I had to select scp protocol to connect successfully. – zar Mar 4 '14 at 14:50

You can also try this:

scp -r /cygdrive/c/desktop/myfolder/deployments/ user@host:/path/to/whereyouwant/thefile
share|improve this answer
2  
This answer will only work if you have cygwin installed and you are running in a cygwin shell or using a cygwin executable. But this is a valid answer that will work for some people. – Jason Jul 14 '15 at 23:31

I have found it easiest to use a graphical interface on windows (I recommend mobaXTerm 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

share|improve this answer
    
downloaded that mobaXTerm and turned out it had a virus. Messed up some stuff for me good – Damien Oct 6 '16 at 13:55
    
@Damien then you did not download it from the site I provided – hehe3301 Feb 22 '17 at 18:24

Drive letter can be used in the source like

scp /c/path/to/file.txt user@server:/dir1/file.txt
share|improve this answer
1  
cp: cannot stat ‘/c/Users/xxx/Documents/rocket.chat/priv-key.ppk’: No such file or directory – Nino Škopac Jul 14 '16 at 13:26
    
'/drives/c/Users/xxx/Documents/rocket.chat/priv-key.pp" will work – David Poxon Nov 19 '16 at 1:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.