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?

  • Is this the exact format of the command you ran? Or was there a file name after the ':'?
    – dtyler
    Oct 12, 2011 at 16:20
  • I think, the edit is cunfusing as there seems to be virtually no difference between the question and the accepted answer. According to this comment, the error was because of relative vs absolute path.
    – Cadoiz
    Mar 8, 2022 at 9:43

5 Answers 5


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 .
  • 2
    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. Oct 12, 2011 at 16:31
  • @StéphaneGimenez now that I see the edited answer I understand. It seemed a strange question :-)
    – Matteo
    Oct 12, 2011 at 17:57
$ scp username@remoteip:remote_location_file /location/where/you/save

Just as a note: This only works when you copy file. if you want to copy a directory use

$ scp -r username@remoteip:remote_location_directory /location/where/you/save

We already saw the recursive option in the second command. This and a further selection of options you may use on your demand are listed from the man page:

  • -r
    Recursively copy entire directories.

  • -P port
    Specifies the port to connect to on the remote host. Note that this option is written with a capital "P", because -p is already reserved for preserving the times and modes of the file in rcp.

  • -p
    Preserves modification times, access times, and modes from the original file.

  • -v

    Verbose mode. Causes scp and ssh to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.

  • 1
    The OP asked for copying a file, not a directory. Nov 30, 2016 at 13:16

use proper scp path

scp ssh://user@hostname/tmp/foo.txt .

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 [email protected]:docs/foo.txt .
scp [email protected]:/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 [email protected]:'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 [email protected]:/ host.example.com
cp host.example.com/path/to/file .

One can SCP both way easily if one has the DMZ user and Password You are at your local machine: From DMZ to your local linux machine (pull). Means copy abc.text inside folder2 to your current logged-in PWD.

scp user@111111:folder1/folder2/abc.txt .

It will ask for password

thats all

Now you want to send a folder will subfolders and files from your local machine to DMZ:

usr@localmachine:~/abc/defs>  scp -r folder/ usr@111111:vkrishna/docker/

again password will be asked

: is the root folder of the remote machine and vkrishna is a folder there & again docker subfolder. Locally defs folder has a folder called folder that we want to completely transfer.

Like /abc/defs/folder

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .