Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

with scp I can get a file

 scp remoteA:file .

and put a file

 scp file remoteB:

but when I try

 scp remoteA:file remoteB:

I get

ssh: Could not resolve hostname remoteB: Name or service not known
lost connection



the remoteA and remoteB description is in ~/.ssh/config

share|improve this question
Using scp to copy between two remote hosts works perfectly fine for me. Are you sure you haven't made a typo in your command (like you have made in your question title)? – aland Apr 30 '12 at 16:31
up vote 2 down vote accepted

likely not related to scp itself, but some sort of name resolution from one host to another. another thing to consider is authentication. it is best you have a passphrase-less key auth from A to B. in which host's .ssh/config you are defining these hosts? scp is not finding that definition. try the real fqdn of the host and it should work fine, if host definition is the problem. also, use -v to see if more details can be found for the error.

share|improve this answer
If you're able to ssh into remoteA, can you connect from remoteA to remoteB? – Doug Harris Apr 30 '12 at 17:26

You need to specify a host which remoteA can reach because the copy is made from remoteA directly to remoteB.

To avoid this you can use the -3 option. man scp says what it does:

Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option disables the progress meter.

share|improve this answer

Your Answer


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.