Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------
- Opens a reverse ssh connection to "username@host", forwarding "port" to the local ssh.
- Retries every 3 minutes if the forwarding (or the connection) fails
- ----------------------------------------
- #!/bin/bash
- for (( ; ; ))
- do
- ssh -g -o "ExitOnForwardFailure yes" -R port:localhost:22 username@host
- sleep 180
- done
- ----------------------------------------
- Script that adds another route to internet. Add table "admin" to /etc/iproute2/rt_tables once before running the script the first time. Here, 10.0.0.138 is the router, eth0 is the network device that connects to the secondary route.
- ----------------------------------------
- #!/bin/bash
- #Add table "admin" to /etc/iproute2/rt_tables
- myotherdevice=eth0
- myothernetwork=10.0.0
- myothergateway=10.0.0.138
- myotherip=$(ifconfig | grep $myothernetwork | cut -d: -f2 | cut -f1 -d' ')
- ip route add ${myothernetwork}.0/24 dev $myotherdevice src $myotherip table admin
- ip route add default via $myothergateway dev $myotherdevice table admin
- ip rule add from ${myotherip}/32 table admin
- ip rule add to ${myotherip}/32 table admin
- ip route flush cache
- ----------------------------------------
- Script that downloads a directory using rsync, with resume.
- ----------------------------------------
- #!/bin/bash
- while [ 1 ]
- do
- rsync -avrvv --size-only --partial --progress username@host:/source_dir destination_dir
- if [ "$?" = "0" ] ; then
- echo "Rsync completed normally."
- exit
- else
- echo "Rsync failed. Retrying in 3 minutes."
- sleep 180
- fi
- done
- ----------------------------------------
- Same, but binds the connection to the other interface/route (10.0.0.2 is the assigned ip).
- ----------------------------------------
- #!/bin/bash
- while [ 1 ]
- do
- rsync --address=10.0.0.2 -avrvv --size-only --partial --progress -e 'ssh -oBindAddress=10.0.0.2' username@host:/source_dir destination_dir
- if [ "$?" = "0" ] ; then
- echo "Rsync completed normally."
- exit
- else
- echo "Rsync failed. Retrying in 3 minutes."
- sleep 180
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement