Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:ssh:autossh [2018/08/18 04:19] – [Run as Service] antiverdocs:guide-user:services:ssh:autossh [2022/03/25 10:50] – [Run as Service] trendy
Line 43: Line 43:
 ===== Run as Service ===== ===== Run as Service =====
  
-Autossh is ofen used as reverse proxy. It's probably because your ISP does not give you a publlic address or your router firewall policies. To make autossh run even when router restats, your need to set up a service.+Autossh is often used as reverse proxy. It's probably because your ISP does not give you a public address or your router firewall policies. To make autossh run even when router restarts, your need to set up a service.
  
-In ''/etc/init.d/autossh'', most content of the files has been generated when you first install autossh. But you need add a line ''export HOME=/root'' in ''start_instance()'' or the the service will **NOT** work when the router reboots. This is a known bug not fixed yet. https://github.com/openwrt/packages/issues/5559+In ''/etc/init.d/autossh'', most content of the files has been generated when you first install autossh. But you need add a line ''procd_set_param env HOME="/root"'' in ''start_instance()'' or the the service will **NOT** work when the router reboots. This is a known bug not fixed yet. https://github.com/openwrt/packages/issues/5559
  
  
  
-        local section="$1" +        start_instance() { 
-        config_get ssh "$section" 'ssh' +                local section="$1" 
-        config_get gatetime "$section" 'gatetime' +         
-        config_get monitorport "$section" 'monitorport' +                config_get ssh "$section" 'ssh' 
-        config_get poll "$section" 'poll' +                config_get gatetime "$section" 'gatetime' 
-        config_get_bool enabled "$section" 'enabled' '1' +                config_get monitorport "$section" 'monitorport' 
-        [ "$enabled" = 1 ] || exit 0 +                config_get poll "$section" 'poll' 
-        export HOME=/root +                config_get_bool enabled "$section" 'enabled' '1' 
-        export AUTOSSH_GATETIME="${gatetime:-30}" +                 
-        export AUTOSSH_POLL="${poll:-600}" +                [ "$enabled" = 1 ] || exit 0 
-        export AUTOSSH_DEBUG=+                 
-        service_start /usr/sbin/autossh -M ${monitorport:-20000} -f ${ssh}+                procd_open_instance 
 +                procd_set_param command /usr/sbin/autossh -M ${monitorport:-20000} ${ssh} 
 +                procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5} 
 +                procd_set_param env AUTOSSH_GATETIME="${gatetime:-30}"  
 +                procd_set_param env AUTOSSH_POLL="${poll:-600}" 
 +                procd_set_param env HOME="/root" 
 +                procd_close_instance
  
-Now you can enable the service by ''/etc/init,d/autossh enable'' and enjoy it.+ 
 +Now you can enable the service by ''/etc/init.d/autossh enable'' and enjoy it.
  
 ===== Fixes ===== ===== Fixes =====
 To get ssh working you need to replace ''localhost'' in ''2222:localhost:22'' of the ''ssh'' variable to the local ip.  To get ssh working you need to replace ''localhost'' in ''2222:localhost:22'' of the ''ssh'' variable to the local ip. 
  
  • Last modified: 2023/11/30 22:27
  • by stokito