I would like to know an easy way to use scp
to copy files and folders that are present in different paths on my file system. The SSH destination server requests a password and I cannot put this in configuration files. I know that scp
doesn't have a password parameter that I could supply from a script, so for now I must copy each file or directory one by one, writing my password every time.
From this site:
SSHSOCKET=~/.ssh/myUsername@targetServerName
ssh -M -f -N -o ControlPath=$SSHSOCKET myUsername@targetServerName
scp -o ControlPath=$SSHSOCKET myUsername@targetServerName:remoteFile.txt ./
ssh -S $SSHSOCKET -O exit myUsername@targetServerName
It's intuitive, safer than creating a key pair, faster than creating a compressed file and worked for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With