Mailinglist Archive: opensuse (1239 mails)

< Previous Next >
[opensuse] Has anyone ever used the autossh daemon?
  • From: Greg Freemyer <greg.freemyer@xxxxxxxxx>
  • Date: Sun, 2 Jun 2013 16:19:14 -0400
  • Message-id: <>

I've struggled to setup autossh as daemon and just got it working. I
hope it is reliable because I'm about to drive away and won't be back
for a while. If anyone can comment on it's reliability, I'd
appreciate feedback

Now that I have port 22 (ssh) working, I haven't yet figured out the
syntax for port 80 so any help on my second line below would be great.

Also, anything else I should do to make this connection more robust?
(I hope I have the monitoring port below set right?)

Details for myself or others that want to do this:

autossh is designed to let you setup a reverse tunnel. That way I can
have a machine behind a NAT firewall expose ssh by tunneling it
through a server on the internet.

Step one:
Get this to work as the user you will log into the public server as:
ssh user@xxxxxxxxxxxxxxxxxxxxxxxxx

Then copy the ssh keyfile to /root/id_rsa_user (there may be a
better way to do that)
chown root.root /root/id_rsa_user
chmod 600 /root/id_rsa_user

Get this to work as root
ssh -i /root/id_rsa_user user@xxxxxxxxxxxxxxxxxxxxxxxxx

# replace user with the user name you setup on the well-known server
and of course replace the server name.
# make sure you accept the cert so that the above works without user interaction

Then enable autossh as daemon. (I used yast service level editor to do that.)

Finally edit /etc/sysconfig/autossh to have
## Type: string
## Default: 0
## Format: <port>[:echo_port]
# The base monitoring port to use, or alternatively, the monitoring
# port and the echo service port to use. Setting 0 will turn the
# monitoring off, and autossh will only restart ssh on ssh exit.

## Type: integer
## Default: 1
# Number of autossh instances to spawn on start.

## Type: string
## Default: user@xxxxxxxxxxx -p 22 -ynNT -R 30000:localhost:22
-o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o
# Options to be passed to ssh
# All options except for the first must end with "_<number>". Only the
# options upto "_$(($AUTOSSH_SPAWNS-1))" will be started.
AUTOSSH_OPTIONS="user@xxxxxxxxxxxxxxxxxxxxxxxxx -i /root/id_rsa_user
-p 22 -ynNT -R 30000:localhost:22 -o ExitOnForwardFailure=yes -o
ServerAliveInterval=60 -o ServerAliveCountMax=3"
AUTOSSH_OPTIONS_1="user@xxxxxxxxxxxxxxxxxxxxxxxxx -i /root/id_rsa_user
-p 22 -ynNT -R 8888:localhost:80 -o ExitOnForwardFailure=yes -o
ServerAliveInterval=60 -o ServerAliveCountMax=3"

Again, the line for port 80 is not yet right. I'm not sure what is
wrong with the above, but I'm tired of working on this for a while.

fyi: the endpoint for this is just a weatherstation, so don't waste
your time trying to hack it. Success will get you to nothing of value
on a network with nothing of value. Also I changed the port away from
30000 (the default)

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups