I am trying to connect to 3 different remote machines, copy files between these machines and then stay in the final remote machine to perform a few tasks. I am trying to create a bash script to help me automate this process. Here is what I will like to do
fname='file to be copied across these remote machines'
rmt1='remote machine1'
mt2='remote machine2'
rmt3='remote machine3'
#copy file from local to rmt1
scp -r $fname $rmt1
#log into rmt1
ssh -Y $rmt1
#from rmt1, copy file from rmt1 to rmt2
scp -r $fname $rmt2
#from rmt1 log into rmt2
ssh -Y $rmt2
#from rmt2 copy file from rmt2 to rmt3
scp -r $fname $rmt3
#from rmt2 log into rmt3
ssh -Y $rmt3
Then finally stay in rmt3 where I can do other things.
I need a bash script to help me automate this process so that I don't have to type so much each time I need to do this. Any help will be highly appreciated. Note I have enabled public/private keys using ssh-keygen so any of these does not require me to enter a password
Many thanks in anticipation for your help
https://shellcheck.net, a syntax checker, or installshellchecklocally. Make usingshellcheckpart of your development process.scp -r $fname $rmt3usescp -r "$fname" "$rmt3"