Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C
  2.  
  3. cd ~/.ssh/
  4.  
  5. echo "ServerAliveInterval 180" >> config
  6.  
  7. ServerAliveCountMax xxxx (high number)
  8.  
  9. while true
  10. do
  11. ssh <ssh_options> [user@]hostname
  12. sleep 15
  13. done
  14.  
  15. tun1:2345:respawn:/usr/bin/ssh -i /path/to/rsaKey -f -N -o "ServerAliveInterval 180" -R 55002:localhost:22 user@publicip 'sleep 365d'
  16.  
  17. start on net-device-up IFACE=eth0
  18. stop on runlevel [01S6]
  19. respawn
  20. respawn limit 180 900
  21. exec ssh -i /path/to/rsaKey -N -o "ServerAliveInterval 180" -R 55002:localhost:22 user@publicip
  22. post-stop script
  23. sleep 5
  24. end script
  25.  
  26. ~/.ssh/config
  27.  
  28. ServerAliveInterval 15
  29. ServerAliveCountMax 4
  30.  
  31. ServerAliveCountMax
  32. Sets the number of server alive messages (see below) which may be
  33. sent without ssh(1) receiving any messages back from the server.
  34. If this threshold is reached while server alive messages are
  35. being sent, ssh will disconnect from the server, terminating the
  36. session. It is important to note that the use of server alive
  37. messages is very different from TCPKeepAlive (below). The server
  38. alive messages are sent through the encrypted channel and there‐
  39. fore will not be spoofable. The TCP keepalive option enabled by
  40. TCPKeepAlive is spoofable. The server alive mechanism is valu‐
  41. able when the client or server depend on knowing when a connec‐
  42. tion has become inactive.
  43.  
  44. The default value is 3. If, for example, ServerAliveInterval
  45. (see below) is set to 15 and ServerAliveCountMax is left at the
  46. default, if the server becomes unresponsive, ssh will disconnect
  47. after approximately 45 seconds. This option applies to protocol
  48. version 2 only.
  49.  
  50. ServerAliveInterval
  51. Sets a timeout interval in seconds after which if no data has
  52. been received from the server, ssh(1) will send a message through
  53. the encrypted channel to request a response from the server. The
  54. default is 0, indicating that these messages will not be sent to
  55. the server. This option applies to protocol version 2 only.
  56.  
  57. [Unit]
  58. Description=SSH Tunnel
  59. After=network.target
  60.  
  61. [Service]
  62. Restart=always
  63. RestartSec=20
  64. User=sshtunnel
  65. ExecStart=/bin/ssh -NT -o ServerAliveInterval=60 -L 5900:localhost:5900 user@otherserver
  66.  
  67. [Install]
  68. WantedBy=multi-user.target
  69.  
  70. screen
  71. ssh -R ......
  72.  
  73. screen
  74. Ctrl + a + d
  75.  
  76. #!/bin/bash
  77. read -s -p "Password: " pass
  78. while true
  79. do
  80. sshpass -p "$pass" ssh user@address -p port
  81. sleep 1
  82. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement