I am writing a bash script to rsync
multiple files from a remote host into my personal computer.
What I wrote so far works, one rsync
command after the other (three in total), though I have to input my ssh password after each execution of rsync
#!/bin/bash
# create the command line argument, that will be PASSED when calling the script
while getopts r: option
do
case "${option}"
in
r) RUNNAME=${OPTARG};;
esac
done
# create the directory on the Toshiba hard Drive
mkdir -p /media/user/TOSHIBA\ EXT/novaseq/$RUNNAME/InterOp
mkdir -p /media/user/TOSHIBA\ EXT/novaseq/$RUNNAME/Unaligned/Stats
# rsync the files into the "base directory"
# the files that have to be rsynced have the extension .csv, .txt and .xml
rsync -avzh user@remote-host:/nexusb/Novaseq/$RUNNAME/*.* /media/user/TOSHIBA\ EXT/novaseq/$RUNNAME/ && rsync -avzh user@remote-host:/nexusb/Novaseq/$RUNNAME/InterOp/*.bin /media/user/TOSHIBA\ EXT/novaseq/$RUNNAME/InterOp && rsync -avzh user@remote-host:/nexusb/Novaseq/$RUNNAME/Unaligned/Stats/*.* /media/user/TOSHIBA\ EXT/novaseq/$RUNNAME/Unaligned/Stats
Is there a way to call the three rsync
commands while inputting the ssh password only once instead of thrice?