monitoring local lan server on main munin server

Flattr this!

I want to monitor my hostname.cavebeat.lan servers on my main server on the internet, to have from everywhere access to the monitoring. My internet connection at home is with dynamic ip so opening a port is not a good solution. DynDNS is also not the best thing and stable.

Searched the net for an easy setup without the need of openVPN or other tunnel software.

SSH Reverse proxy

one of the best tutorials out there is from http://www.vdomck.org/2005/11/reversing-ssh-connection.html

and more advanced with autossh: http://www.vdomck.org/2009/11/ssh-all-time.html

#!/bin/sh
# ------------------------------
# autossh reverse tunnel on boot
# ------------------------------

# This is the username on your local server who has public key authentication setup at the middleman
USER_TO_SSH_IN_AS=username

# This is the username and hostname/IP address for the middleman (internet accessible server)
MIDDLEMAN_SERVER_AND_USERNAME=root@domain.tld

# The following two numbers can be whatever you want, but need to be unique if you have multiple reverse ssh tunnels
# Port that the middleman will listen on (use this value as the -p argument when sshing)
PORT_MIDDLEMAN_WILL_LISTEN_ON=20005

# Connection monitoring port, don't need to know this one
AUTOSSH_PORT=27554

# Ensures that autossh keeps trying to connect
AUTOSSH_GATETIME=0

export AUTOSSH_PORT AUTOSSH_GATETIME

su -c "autossh -f -N -R *:${PORT_MIDDLEMAN_WILL_LISTEN_ON}:localhost:4949 ${MIDDLEMAN_SERVER_AND_USERNAME} -p 22 -oLogLevel=error -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no" $USER_TO_SSH_IN_AS

When i start this script, the Server domain.tld is able to access port 4949 via 20005 from my local lan munin monitored node.

[hostname.cavebeat.lan]
    address 127.0.0.1
    use_node_name yes
    port 20005

 

Odin_hrafnar

easy as that

 

 

Comments are closed.