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?
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:
to send it over, and
to get it back.
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.
Edit: Are you positive you are entering in a valid path in the scp command? For example:
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.,
Send a file:
Get a file:
Send a file from my Desktop to my home folder on a remote server:
Send a file to the the webroot:
In this example, the user john_doe would need write privileges on the remote /var/www directory.
just in case you are including other scp parameters be sure to place these before the source and targets. eg this works:
but this doesn't: