I am trying to copy a .tar archive from remote server to my pc.

Directory of the archive that I want to copy:




I connect to remote server and use the command:

canserhan@embserv:~/tar_files$ scp canserhan@embserv:~/tar_files/rtl_archive.tar serhan@serhan-Lenovo-B560:~Documents$
ssh: serhan-Lenovo-B560: Name or service not known
lost connection

There must be something wrong with the scp syntax I am using. However I could not figure it out. Could you please help me?


  • 1
    Did you add serhan-Lenovo-B560 as a hostname? – Rinzwind May 15 '12 at 9:08
  • Pleas provide the output of ssh serhan@serhan-Lenovo-B560. I think there is a wrong $ at the end of the line, but I don't think that this causes the error message. – lumbric May 15 '12 at 9:16
  • @lumbric I tried it from a different PC and here is the output: canserhan@ubuntu:~$ ssh canserhan@ubuntu canserhan@ubuntu's password: Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-24-generic x86_64) * Documentation: help.ubuntu.com The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. – Amadeus Bachmann May 15 '12 at 22:39
  • Ok, that means the SSH connection seems to be ok. I added an answer. – lumbric May 16 '12 at 14:52

As a rule if you wanna send something to the remote server via scp:

scp some_files.tar user@remoteHost:
scp some_files.tar user@remoteHost:Documents/newname.tar

But if you wanna download something:

scp user@remoteHost:Documents/foo.tar ~/Desktop
scp user@remoteHost:/any/other/dir/foo.tar .

From the scp man page:

 -3      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.

I'd suggest that the problem is that your machine embserv cannot "see" your other machine serhan-Lenovo-B560, or, if it can, it can't resolve the name.

When you invoke scp with two remote machines, what it actually tries to do is something like this:

ssh canserhan@embserv "scp ~/tar_files/rtl_archive.tar serhan@serhan-Lenovo-B560:~Documents$"

That's a Good Thing as it means the copy will be more efficient, but it requires that scp from machine A to machine B works, which it won't always.

If that is the problem, you can solve it by using -3, or by passing the numeric IP address of serhan-Lenovo-B560 (if the name is the problem), or by fixing your ssh setup on embserv so that it can reach serhan-Lenovo-B560.


So, try this:

scp canserhan@embserv:~/tar_files/rtl_archive.tar serhan@xxx.xxx.xxx.xxx:~Documents$

where xxx.xxx.xxx.xx is your server's IP address.

or, if that fails, this should definitely work, but will run more slowly:

scp -3 canserhan@embserv:~/tar_files/rtl_archive.tar serhan@serhan-Lenovo-B560:~Documents$

By the way, ~Documents$ also looks wrong. Are you sure it shouldn't be ~/Documents ?

  • I tried to pass the numeric IP address as follows (again I think I did something wrong with the syntax): canserhan@embserv:~$ scp ~/tar_files/rtl_archive.tar 2xx.1xx.1x.8x However, it created a directory named 2xx.1xx.1x.8x and copied ~/tar... to that directory. But when I did ls 2xx.1xx.1x.8x it said no such directory and also it let me delete that directory. I did not understand anything. If that directory have never existed then how come I could delete it? Was is something like a temp? Also I could not solve my problem by using -3. How can I fix my ssh setup on embserv? – Amadeus Bachmann May 15 '12 at 22:58
  • 2
    If you put a colon : on the end then scp thinks it's a machine name. If you don't then it assumes it's a file name. So, scp ~/tar_files/rtl_archive.tar 2xx.1xx.1x.8x is exactly the same as if you had used cp. I'll edit my answer. – ams May 16 '12 at 9:15
  • +1 for the -3 bit. I could ssh into a machine but scp was giving "Could not resolve hostname xxx: Name or service not known". Using the -3 option fixed it. – Jon McClung Mar 21 at 18:03

Try the command:

scp ~/tar_files/rtl_archive.tar serhan@serhan-Lenovo-B560:~/Documents/

embserv is your local machine. If you write scp server1:/path/to/file server2:/path/to/second/file this instructs scp to copy a file from one server to a second server. If you want to copy a local file to a server or the other way round just skip the colons : and the machine name. In additon ~ has to be followed by a slash in your case. ~ translates to /home/username/.

  • The command ending of user@hostname:~/Documents/ is the same as user@hostname:Documents/. The default destination path is /home/<user>/. – david6 Jun 23 '13 at 2:09

I believe that you don't have a DNS at your network.. It looks as if though it cannot resolve your name serhan-Lenovo-B560

You can try one thing, just type the IP of remote end.

$ scp canserhan@embserv:~/tar_files/rtl_archive.tar serhan@<remote-ip>:~Documents

Moreover, try giving full/absolute path instead of ~.

Your Answer

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

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