Bash – Error while using scp

bashscp

I use "scp" command in my shell script. How do I get the error log , if that command is not working.

This is how I am using it scp file username@servername:/specificdirectory/

Best Answer

If you encounter an error while running scp, try doing ssh first to the server, scp doesn't have a graceful handling of new keys and ssh is more verbose with error reporting by default.

To get a more detailed log of what is happening, try running it with -v:

scp -v file username@servername:/specificdirectory/

You must also remember that path starting with / are absolute, not relative to your home directory, as such you may want to try:

scp file username@servername:specificdirectory/