summaryrefslogtreecommitdiff
path: root/localautossh
blob: 053394d1f38de6c3fe913919302a32e49ae7d746 (plain)
  1. #!/bin/sh
  2. #
  3. # Example script to start up tunnel with autossh.
  4. #
  5. # This script will tunnel 2200 from the remote host
  6. # to 22 on the local host. On remote host do:
  7. # ssh -p 2200 localhost
  8. #
  9. # $Id: localautossh,v 1.2 2008-03-28 09:28:55 jonas Exp $
  10. #
  11. if [ -z "$SSH_ASKPASS" ]; then
  12. export SSH_ASKPASS="ssh-askpass"
  13. fi
  14. if [ "X$SSH_AUTH_SOCK" = "X" ]; then
  15. eval `ssh-agent -s`
  16. ssh-add $HOME/.ssh/id_rsa
  17. fi
  18. remoteport="2200"
  19. if [ -n "$2" ]; then
  20. remoteport="$(expr 2200 + "$2")"
  21. fi
  22. #AUTOSSH_POLL=600
  23. #AUTOSSH_PORT=20000
  24. #AUTOSSH_GATETIME=30
  25. #AUTOSSH_LOGFILE=$HOST.log
  26. #AUTOSSH_DEBUG=yes
  27. #AUTOSSH_PATH=/usr/local/bin/ssh
  28. export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT
  29. autossh -2 -fN -M 20000 -R $remoteport:localhost:22 "$1"