User Tools

Site Tools


doc:howto:autossh

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
doc:howto:autossh [2013/07/08 15:40]
tmomas spelling correction
doc:howto:autossh [2017/10/13 18:03] (current)
tmomas Applied proper formatting to Installation steps
Line 1: Line 1:
 +====== Autossh ======
 +Autossh monitors a ssh connection and reconnects the ssh-session if the connection fails.
 +
 +To automatically log in you need to use an authentication key.
 +
 +The package, slightly outdated, can be found in the '​oldpackages'​ feed.
 +
 +Alternative packages:
 +
 +  * [[https://​github.com/​hewenhao2008/​autossh-openwrt]]
 +  * [[https://​github.com/​aa65535/​openwrt-autossh]]
 +
 +[[doc:​uci:​sshtunnel|sshtunnel]] is a simpler, functionally-identical package. (depends on OpenSSH so higher disk space requirements)
 +
 +===== Use Case =====
 +  * You want to forward a local port (e.g. the webserver/​ssh) to a remote server.
 +  * If your client running OpenWrt is behind a NAT, this allows to connect to a server that is not behind a NAT and create a reverse tunnel to the local ssh server.
 +
 +===== Installation =====
 +  - Install autossh <​code>​opkg install autossh</​code>​
 +  - Create a key <​code>​dropbearkey -t rsa -f /​etc/​dropbear/​id_rsa</​code>​
 +    * On //**LEDE** 17.01.x// use <​code>​dropbearkey -t rsa -f /​root/​.ssh/​id_dropbear</​code>​
 +  - ''​dropbearkey''​ will print the public key, starting with ''​ssh-rsa''​.
 +    * You can reprint the key using <​code>​dropbearkey -y -f /​etc/​dropbear/​id_rsa</​code>​
 +    * or you can write it to a file (e.g. ''/​tmp/​pubkey''​) <​code>​dropbearkey -y -f /​etc/​dropbear/​id_rsa | grep ssh-rsa > /​tmp/​pubkey</​code>​
 +  - Add the key to the ''​authorized_keys''​ file on your server, e.g. copy pubkey file to the server and do <​code>​cat pubkey >> ~/​.ssh/​authorized_keys</​code>​
 +
 +===== Configuration =====
 +Autossh is configured using the [[doc/uci | Unified Configuration Interface]] (''/​etc/​config/​autossh''​). ​
 +
 +===== Fixes =====
 +To get ssh working you need to replace ''​localhost''​ in ''​2222:​localhost:​22''​ of the ''​ssh''​ variable to the local ip.