Copying remote file to a specified path on local desktop using scp

I was trying to copy a file from remote server using SCP but its giving the following error.

bash-3.2$ scp username@server:main.php C:\main.php

ssh: Could not resolve hostname C: hostname nor servname provided, or not known

Its assuming C: as hostname but its just the drive name..Please let me how to specify explicitly like some escaping to get rid of this issue.

If i don't specify the path where to save on local desktop,its working fine.

bash-3.2$ scp username@server:main.php main.php
main.php 100% 29KB 28.9KB/s 00:01

Appreciate any help.. Thanks in advance,

PS: Using Windows XP SP2

0

5 Answers

If you are using Cygwin's scp, you might try using the Cygwin paths:

scp user@host:main.php /cygdrive/c/main.php

You could also use the pscp and psftp commands included in the PuTTY package – they are native Win32 programs and won't complain about Windows paths.

Alternatively, WinSCP is a good SCP/SFTP client (primarily a GUI, though also comes with a command-line tool).

3

Use PSCP.exe

The problem you are having is because you are referencing your windows xp drive from the shell which you cannot do. You are logged on remotely to a machine so unless your windows xp box has a ssh server running in which case you would use login and pw info for the destination location, you will cannot do that.

Using pscp.exe (free) you can do what you want.

0

@grawity is right. In the future, you can run also

pwd

to find out what directory you're in, so that you can figure out the correct path to the directory you want according to cygwin.

I had the similar problem and had success using:

scp username@server:main.php /c/main.php

which is only sort of mentioned by the others.

1

related: I needed to use local variables in the path, and found using cygpath was very helpful.

e.g.

scp $MY_FILE ubuntu@192.128.23.23

become:

scp `cygpath $MY_FILE ` ubuntu@192.128.23.23 

ironically, just: echo $MY_FILE alone was giving a cygwin path, but used in the scp command, it somehow was not, and spit out that same error, ssh: Could not resolve hostname C: hostname nor servname provided, or not known

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like