Advertisement
Guest User

SSHFS auto-connect script

a guest
Dec 21st, 2014
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. ip1=192.168.1.1 # Replace with your IP address or DNS name, user name, port etc.
  2. user1=somelogin
  3. aut1='-o PasswordAuthentication=no'
  4. port1='-p 59184'
  5.  
  6. ip2=192.168.1.2 # Replace with your IP address or DNS name, user name, port etc.
  7. user2=somelogin
  8. pass2='-o password_stdin'
  9. port2='-p 59184'
  10. aut2='-o workaround=rename'
  11.  
  12. dir1=/some/remote/source/ # Replace with the directory on the remote computer
  13. dir2=/home/remotelogin/
  14.  
  15. r=1
  16. c=0
  17. until [ $r = 0 ]
  18. do
  19. if test $c -gt 120
  20. then
  21. exit 1
  22. fi
  23. ping -c 2 $ip1
  24. r=$?
  25.  
  26. c=`expr $c + 1`
  27. sleep 5
  28. done
  29. sshfs $user1@$ip1:$dir1 /home/localuser/SSHFSFOLDER $port1 $aut1 # Replace with your local folder path
  30.  
  31. r=1
  32. c=0
  33. until [ $r = 0 ]
  34. do
  35. if test $c -gt 120
  36. then
  37. exit 1
  38. fi
  39. ping -c 2 $ip2
  40. r=$?
  41.  
  42. c=`expr $c + 1`
  43. sleep 5
  44. done
  45.  
  46. echo mypassword | sshfs $user2@$ip2:$dir2 /home/localuser/SSHFSFOLDER2 $port2 $aut2 $pass2 # Replace with your local folder path and your password!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement