SSH – Fixing ‘scp: Cannot Stat File’ Error

scpssh

I have file on remote machine. I can list it:

ssh matous@xxx ls -la

the file is in the reponse:

...
-rw-r--r-- 1 matous matous 796672 Oct 11 11:12 D1.db
...

Now If I try to scp it to my local machine:

scp matous@xxx/D1.db /home/matous

I get error:

cp: cannot stat 'matous@x/D1.db': No such file or directory

How is it possible that file exists and cannot be stated? What I am missing?

Best Answer

The syntax of scp is not correct. Try

scp matous@xxx:D1.db /home/matous

Without the colon (:), scp will try to interpret matous@xxx/D1.db as a local path.

Note that I omitted the leading /. If you would use scp matous@xxx:/D1.db, then scp would try to copy from /D1.db but this file appears to be in the home directory, which is the default path for scp to operate in.