Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I am on machine A and want to pull a file from machine B.

A$ scp <myuserid>@hostB:<path of file in B> .

it says that:

scp: <path of file in B>: No such file or directory

But on machine B, this file exists in this path.

What is going wrong?

share|improve this question
Is this the exact format of the command you ran? Or was there a file name after the ':'? – dtyler Oct 12 '11 at 16:20
up vote 22 down vote accepted

You didn't specify any file: you have to add the file (with path) after the colon:

A$ scp <myuserid>@hostB:/absolutepath/file .


A$ scp <myuserid>@hostB:relativepath/file .

for a path relative to your home directory.

If you don't specify a different user (i.e., the user on A and B are the same) you don't need the @

A$ scp hostB:/path/file .
share|improve this answer
I fixed the formatting in the question, but maybe your answer is still valid. The problem might come from a confusion between absolute and relative (to home) paths. – Stéphane Gimenez Oct 12 '11 at 16:31
@StéphaneGimenez now that I see the edited answer I understand. It seemed a strange question :-) – Matteo Oct 12 '11 at 17:57

use proper scp path

scp ssh://user@hostname/tmp/foo.txt .
share|improve this answer

You can specify either a file path that is relative to your home directory, or an absolute file path. For example, if foo.txt is in a directory called docs under your home directory and bar.txt is in /var/tmp, you can do

scp username@host.example.com:docs/foo.txt .
scp username@host.example.com:/var/tmp/bar.txt .

Note that if the file name contains characters that are special to the remote shell (typically whitespace or !"#$&'*;<>?[\]^`{|}~), you need to escape them for the remote shell in addition to escaping them for the local shell. For example, if the file is called foo bar.txt and is in your home directory:

scp username@host.example.com:'foo\ bar.txt' .

If you have difficulties with files containing punctuation characters, try using sftp instead of scp to transfer them. Or use an even more convenient method, if you can use FUSE: mount the remote machine's filesystem using sshfs, and then use ordinary file manipulation commands.

mkdir host.example.com
sshfs username@host.example.com:/ host.example.com
cp host.example.com/path/to/file .
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.