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:02] – [Configuration] antiverdocs:guide-user:services:ssh:autossh [2022/03/25 10:50] – [Run as Service] trendy
Line 40: Line 40:
  
 You need to eplace ''/root/.ssh/dropbear'' with your key generated by dropbear. You need to eplace ''/root/.ssh/dropbear'' with your key generated by dropbear.
 +
 +===== Run as 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 ''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
 +
 +
 +
 +        start_instance() {
 +                local section="$1"
 +        
 +                config_get ssh "$section" 'ssh'
 +                config_get gatetime "$section" 'gatetime'
 +                config_get monitorport "$section" 'monitorport'
 +                config_get poll "$section" 'poll'
 +                config_get_bool enabled "$section" 'enabled' '1'
 +                
 +                [ "$enabled" = 1 ] || exit 0
 +                
 +                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.
 +
 ===== 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