scp was working fine, but now when I do

$ scp /path/to/local/file myusername@servername.com

it doesn't ask for my password, but returns nothing immediately, and a new file named "myusername@servername.com" is created in the directory.

Also, I have not problem ssh to server, it asks for my password and I could log in successfully.

$ ssh myusername@servername.com

I did some configuration to set up VIM as IDE for C++ over the weekend, so I might have messed something? I've also created a new anaconda environment for running Python3, if these information help.


You need to tell scp you're copying to a remote, using : and (optionally) a path on the target:

scp /path/to/local/file myusername@servername.com:/path/to/remote

If you just specify : it will use the default path, probably myusername's home directory on servername.com:

scp /path/to/local/file myusername@servername.com:

(Thanks to Stephen Harris for pointing out that the remote path is optional.)

  • 5
    You typically don't need a remote path, but you do need the :. – Stephen Harris Sep 21 '16 at 17:07

Because scp can be used to copy files to a server, or from a server the program uses the presence of the : to determine which way to send. Without a : there is no hostname and so it assumes both files are local.


scp x a@b

will treat both x and a@b as local files.

You don't need to specify a target path, but you do need the :

scp x a@b:

If there's no path specified then it will use the default directory (typically the remote $HOME), same as if you'd specified a@b:.


By default, scp assumes that you want a local file unless you specify where you want the file on the remote server with :.

For example, scp /path/to/local/file myusername@servername.com:./ will do what you intend: to create a file at the default directory of myusername on servername.com called file with the contents of /path/to/local/file on your computer.

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.