4

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

why?

EDIT:

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

juanpablo
  • 7,424

3 Answers3

7

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.

2

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.

johnshen64
  • 4,701
0

For those who come here because scp accuses a local file of being a hostname which it can't resolve (another source of Name or service not known), such as:

> scp archive_2017-03-01-09:54:02.tar.gz backupserver:/var/backups/
ssh: Could not resolve hostname archive_2017-03-01-09:54:02.tar.gz: Name or service not known

Workaround:

> scp ./archive_2017-03-01-09:54:02.tar.gz backupserver:/var/backups/
user2394284
  • 1,861