I usually need to scp stuff from/over-to servers on a regular basis. And here is a function in .bashrc that I use:
#function to get the scp path to here
function scp2here
{
user=`whoami`
server=`hostname`
pathToHere=`pwd`
output=$user"@"$server":"$pathToHere
if [ ! -z "$1" ]
then
output=$output"/"$1
fi
echo $output
}
This function prints out the scp command argument to copy a file/directory to a location.
Examples
Then to copy something to a target server where I have scp2here, I can cd to the target directory and do this:
srasul@some.cool.host ~ $ scp2here srasul@some.cool.host.com:/home/srasul ... srasul@another.cooler.host ~ $ scp bigassfile.txt srasul@some.cool.host.com:/home/srasul
Or if I want to copy a file from a location that has scp2here:
srasul@some.cool.host ~ $ scp2here somefile.txt
srasul@some.cool.host.com:/home/srasul/somefile.txt
...
srasul@another.cooler.host ~ $ scp srasul@some.cool.host.com:/home/srasul/somefile.txt .