I'm looking to list all files in a folder:
ABC123.cfg
XYZ456.cfg
EFG999.cfg
The file names, without the .cfg
relate to a remote server name, ABC123
etc.
I want to copy a couple of files to each of the remote servers.
So, look up the filenames, but take the name without the .cfg
. Then
scp filename.txt username@ABC123:/home/username/
For each remote server, overwriting the destination file if exists.
Each remote server uses the same username and password.
Can I use a password in the scp
command?
sshpass -p
. Even its manual notes that it's not very safe on most systems. Just useSSHPASS=$password sshpass -e ...
instead. – ilkkachu Dec 02 '17 at 18:54read -rs pass; SSHPASS=$pass sshpass -e ...
But then we're probably getting to the point where using ssh keys andssh-agent
would be smartest – ilkkachu Dec 02 '17 at 19:58