Created
December 28, 2012 04:06
-
-
Save stefanocudini/4394360 to your computer and use it in GitHub Desktop.
make tunnel autossh for mounting remte nfs resource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # crea un tunnel ssh che si ricollega in caso di disconnessione | |
| #trasferisce in Remoto sulla porta PREMOTE la porta local PLOCAL | |
| SERV=easyblog.it | |
| USER=tunnel | |
| P_SSH_L=22 | |
| P_SSH_R=2222 | |
| P_HTTP_L=80 | |
| P_HTTP_R=8888 | |
| P_NFS_L=2049 | |
| P_NFS_R=2049 | |
| P_MNT_L=$(netstat -ltnp | grep rpc.mountd | cut -d':' -f2 | cut -d' ' -f1) | |
| P_MNT_R=2050 | |
| PKEY=/ffp/home/root/.ssh/id_rsa | |
| #AUTOSSH_LOGLEVEL 3 | |
| AUTOSSH_LOGFILE=/ffp/home/root/tunnel-autossh.log | |
| export AUTOSSH_LOGFILE | |
| autossh -v -M 0 -q -f -N -i $PKEY -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R $P_NFS_R:localhost:$P_NFS_L $USER@$SERV | |
| autossh -v -M 0 -q -f -N -i $PKEY -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R $P_MNT_R:localhost:$P_MNT_L $USER@$SERV | |
| #autossh -v -M 0 -q -f -N -i $PKEY -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R $P_SSH_R:localhost:$P_SSH_L $USER@$SERV | |
| #autossh -v -M 0 -q -f -N -i $PKEY -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R $P_HTTP_R:localhost:$P_HTTP_L $USER@$SERV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment