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
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!