Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I want to send something via scp to server:

$ scp file server:
                   _____  _____  _____

, then three lines are printed and file is not copied. However I can connect to server via ssh without problem:

$ ssh server

How to make scp work?

share|improve this question
Provide more information such as the operating system, ssh config file, etc. –  qroberts Feb 29 '12 at 16:11
And what are these three lines that are printed? –  jjlin Feb 29 '12 at 17:05
In the normal case, when you run scp file server: (assuming "server" is a valid hostname), the file is copied to your account directory. –  dan_linder Mar 1 '12 at 19:53
Can you provide the output when you run "scp -v file server:". –  dan_linder Mar 1 '12 at 19:54
add comment

3 Answers

up vote 10 down vote accepted

One possible cause of this type of behavior is having any message print out during the login process on server. Scp depends on ssh to provide a totally transparent encrypted tunnel between the client and the server.

Check all of the login scripts on the server, and also try using a different user. Another method of identifying the source of the error is to use the -v in the command, to trace the progress of the transaction, and see where it fails. You can use up to -vvv to increase the verbosity, if necessary. Checking the various forms of scp can also be instructive, as listed in the post by InChargeOfIT.

scp, under the hood, sets up a tunnel using ssh, and then transfers the file over that tunnel, with a ssh command on the far end to catch the file as it comes over. This is illustrated by the use of tar and ssh to copy a directory structure preserving ownership and creation times with the following commands:

  tar czf - ./* | ssh jf@otherserver.com tar xzf - -C ~/saved_tree

to send it over, and

ssh jf@otherserver.com "tar czf - ~/saved_tree" | tar xzvf - -C ./

to get it back.

share|improve this answer
Thank you! i was scratching my head last night!!!! :) –  jtanmay May 3 '13 at 13:35
add comment

Edit: Are you positive you are entering in a valid path in the scp command? For example:

scp test.txt username@remoteserver.com

will fail (in fact, it will just print out the command like you are seeing). In this case, you will need to provide a valid path to the remote server.. e.g., scp test.txt username@remoteserver.com:~/

Example usages:

Send a file:

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

Get a file:

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


Send a file from my Desktop to my home folder on a remote server:

scp ~/Desktop/myfile.txt john_doe@

Remember the ~ is a shortcut for your home directory... e.g., /home/

Send a file to the the webroot:

scp ~/Documents/working/index.html john_doe@johndoe.com:/var/www/index.html

In this example, the user john_doe would need write privileges on the remote /var/www directory.

share|improve this answer
you are not answering the question. the commandline given by OP looks fairly ok, the interesting part are the ------ ... none of your examples relates to that. –  akira Feb 29 '12 at 18:14
@akira maybe, maybe not. Not providing valid paths will cause the scp command to fail.. e.g, scp somefile user@host.com: Also, not having the correct permissions on the remote directory would also cause problems. Edited my answer to make it a little clearer –  InChargeOfIT Feb 29 '12 at 18:17
none of your examples cover "file does not exist", none of your examples cover "permissions wrong on server side"... –  akira Feb 29 '12 at 18:29
Excellent info, thank you –  tjb Sep 23 '13 at 11:03
add comment

Check the target user's .bashrc or equivalent file. ~/.bashrc is sourced for non-interactive logins. If there's an echo or command that outputs anything, it will break the SCP protocol.

share|improve this answer
add comment

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.