Contents
Can you send a file via SCP using sshpass?
Update the question so it’s on-topic for Unix & Linux Stack Exchange. Closed 4 years ago. In my case, I have a situation that I’m trying to send a file via SCP using sshpass but I can’t. I need to use a script with a password but the easiest way doesn’t work
How to use wildcards ( * ) when copying with SCP?
When you want to use wildcards use either single quotes or escape only the asterisk: scp ‘SERVERNAME:/DIR/*’./ # or scp SERVERNAME:/DIR/*./ It seems that scp only supports wildcards for file names but not for directory names.
How does SCP transfer files from one directory to another?
Note that scp follows symbolic links encountered in the tree traversal. So if you have sub-directories inside local_dir, the last example will only transfer files, but if you set the -r option, it will transfer files and directories. Appending /. to your source directory will transfer its contents instead of the directory itself.
Is there a way to automate the SCP command?
The scp command itself is prefaced with sshpass and -o StrictHostKeyChecking=no to fully automate the scp command without user interaction. Looks convoluted but better than hard-coding paths which are expected to change from time to time.
Why is my SCP not working on my computer?
On some hosts they incorrectly source .bash_profile for non-interactive logins like scp. Messages that get printed to the terminal can possibly cause scp to not function correctly. If you have messages in your .bash_profile this can be the cause.
What kind of tunnel does SCP depend on?
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.
What to do when SSH doesn’t work?
When troubleshooting ssh/scp, it’s a good idea to add the -v option for verbose output. You may also want to specific the user on the remote server. Lastly, it is sometimes helpful to copy the file to a temporary place such as /tmp where you know you have write permissions.