diff -Nru autossh-1.4c/debian/changelog autossh-1.4c/debian/changelog --- autossh-1.4c/debian/changelog 2013-11-15 09:57:24.000000000 +0000 +++ autossh-1.4c/debian/changelog 2013-12-18 08:55:41.000000000 +0000 @@ -1,8 +1,8 @@ -autossh (1.4c-2.01~eugenesan~trusty3) trusty; urgency=low +autossh (1.4c-2.02~eugenesan~trusty1) trusty; urgency=medium * Support for automatic sessions/tunnels/proxies - -- Eugene San (eugenesan) Wed, 16 Oct 2013 11:48:32 +0300 + -- Eugene San (eugenesan) Wed, 18 Dec 2013 10:52:36 +0200 autossh (1.4c-2) unstable; urgency=low diff -Nru autossh-1.4c/debian/default autossh-1.4c/debian/default --- autossh-1.4c/debian/default 2013-11-15 09:52:08.000000000 +0000 +++ autossh-1.4c/debian/default 2013-12-18 08:47:39.000000000 +0000 @@ -13,9 +13,8 @@ # Generic parameters (optional) # -AUTOSSH_RUN_DIR="/var/run/user" +AUTOSSH_RUN_DIR="/tmp" #AUTOSSH_DEBUG=yes -#AUTOSSH_LOGFILE="${AUTOSSH_RUN_DIR}/autossh.log" #AUTOSSH_POLL=600 #AUTOSSH_GATETIME=30 #AUTOSSH_LOGLEVEL=9 @@ -26,10 +25,15 @@ # Below parameters must be unset to flush settings between sessions # unset AUTOSSH_SESSION -unset AUTOSSH_LUSER +unset AUTOSSH_LOGFILE +unset AUTOSSH_PIDFILE +unset AUTOSSH_USER +unset AUTOSSH_HOST +unset AUTOSSH_PORT unset AUTOSSH_RUSER unset AUTOSSH_RHOST unset AUTOSSH_RPORT -unset AUTOSSH_PORT -unset AUTOSSH_CONNECTIONS_REMOTE -unset AUTOSSH_CONNECTIONS_LOCAL +unset AUTOSSH_SHOST +unset AUTOSSH_SPORT +unset AUTOSSH_RCONNECTIONS +unset AUTOSSH_LCONNECTIONS diff -Nru autossh-1.4c/debian/default.conf autossh-1.4c/debian/default.conf --- autossh-1.4c/debian/default.conf 2013-10-16 08:51:23.000000000 +0000 +++ autossh-1.4c/debian/default.conf 2013-12-18 08:34:15.000000000 +0000 @@ -1,43 +1,42 @@ # See /etc/init.d/autossh for more information. # # You must fill most variables below to define autossh session -# -# AUTOSSH_RUSER is the unix username of remote user -# AUTOSSH_LUSER is the unix username of local user -# AUTOSSH_HOST is host of remote server to which we will connect -# AUTOSSH_LPORT is port of local SSH server -# AUTOSSH_DPORT is the remote port we will listen on at the remote host -# AUTOSSH_RPORT is the remote port on which remote SSH is listening -# AUTOSSH_PORT is base port used for monitoring connection -# AUTOSSH_LHOST is local host to which we want to forward remote connection -# AUTOSSH_RHOST is remote host on which we will listen for connection (optional) -# Session specific paramters (Leave undefined to skip session during service startup) +# Session specific paramters (Leave as "default" to skip session during service startup) # -#AUTOSSH_SESSION="default" +AUTOSSH_SESSION="default" -# Remote Tunnel/Monitor details -# -AUTOSSH_LUSER=user +# Tunnel/Monitor/Socks details +# AUTOSSH_USER - unix username of local user under which tunnel will be created +# AUTOSSH_HOST - host of local server from which we will connect +# AUTOSSH_PORT - local port on which local monitoring connection will be created +# AUTOSSH_RUSER - unix username of remote user which will be used for remote SSH connection +# AUTOSSH_RHOST - remote host to which remote SSH connection will be created +# AUTOSSH_RPORT - remote port to which remote SSH connection will be created +# AUTOSSH_SHOST - local host on which sosks server will be listening +# AUTOSSH_SPORT - local port on which sosks server will be listening +# +AUTOSSH_USER=user +AUTOSSH_HOST=0.0.0.0 +AUTOSSH_PORT=2222 AUTOSSH_RUSER=user AUTOSSH_RHOST=domain.tld -AUTOSSH_RPORT=443 -AUTOSSH_PORT=3333 -AUTOSSH_SOCKS=8080 -AUTOSSH_SOCKS_HOST=127.0.0.1 +AUTOSSH_RPORT=22 +AUTOSSH_SHOST=127.0.0.1 +AUTOSSH_SPORT=${AUTOSSH_PORT:1:1}0${AUTOSSH_PORT:2:1}0 -# Connecions details for "exporting" local ports -# AUTOSSH_RHOST:AUTOSSH_DPORT:AUTOSSH_LHOST:AUTOSSH_LPORT +# Connecions details for "importing" remote ports +# AUTOSSH_RHOST:AUTOSSH_DPORT:AUTOSSH_HOST:AUTOSSH_PORT # -AUTOSSH_CONNECTIONS_REMOTE=" -0.0.0.0:1231:localhost:22 -0.0.0.0:1232:remote.domain.tld:22 -" +PORT=0; for CONN in \ +localhost:22 \ +machine.local:22 \ +; do AUTOSSH_LCONNECTIONS+=" ${AUTOSSH_HOST}:${AUTOSSH_PORT:0:3}${PORT}:${CONN}"; PORT=$((PORT + 1)); done -# Connecions details for "importing" remote ports +# Connecions details for "exporting" local ports # AUTOSSH_RHOST:AUTOSSH_DPORT:AUTOSSH_LHOST:AUTOSSH_LPORT # -AUTOSSH_CONNECTIONS_LOCAL=" -0.0.0.0:3211:localhost:22 -0.0.0.0:3212:machine.local:22 -" +PORT=0; for CONN in \ +localhost:22 \ +remote.domain.tld:22 \ +; do AUTOSSH_RCONNECTIONS+=" ${AUTOSSH_HOST}:${AUTOSSH_PORT:0:3}${PORT}:${CONN}"; PORT=$((PORT + 1)); done diff -Nru autossh-1.4c/debian/init autossh-1.4c/debian/init --- autossh-1.4c/debian/init 2013-11-15 09:53:52.000000000 +0000 +++ autossh-1.4c/debian/init 2013-12-18 08:52:19.000000000 +0000 @@ -24,7 +24,7 @@ path=$(dirname $exec) service="Automatic SSH session keeper (${prog})" default=/etc/default/$prog -configs=$(for c in /etc/${prog}.d/*.conf; do test -z "${AUTOSSH_SESSION}" || echo -n " "; unset AUTOSSH_SESSION; source ${c}; test -z "${AUTOSSH_SESSION}" || echo -n "${c}"; done; echo) +configs=$(for c in /etc/${prog}.d/*.conf; do test -z "${AUTOSSH_SESSION}" || echo -n " "; unset AUTOSSH_SESSION; source ${c}; test -z "${AUTOSSH_SESSION}" || test "${AUTOSSH_SESSION}" == "default" || echo -n "${c}"; done; echo) retval=0 AUTOSSH_PATH="$sshexec" MAXPAUSE=30 @@ -88,12 +88,15 @@ [ -r ${config} ] || continue [ -r ${default} ] && source ${default} source ${config} - [ -n "${AUTOSSH_SESSION}" ] || continue - mkdir -p ${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER} - chown ${AUTOSSH_LUSER}:root ${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER} - chmod 770 ${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER} - AUTOSSH_PIDFILE="${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER}/autossh-${AUTOSSH_SESSION}.pid" + AUTOSSH_USER_RUN_DIR="${AUTOSSH_RUN_DIR}/`id -u ${AUTOSSH_USER}`" + if [ ! -d "${AUTOSSH_USER_RUN_DIR}" ]; then + mkdir -p "${AUTOSSH_USER_RUN_DIR}" + chown ${AUTOSSH_USER}:${AUTOSSH_USER} "${AUTOSSH_USER_RUN_DIR}" + chmod 770 "${AUTOSSH_USER_RUN_DIR}" + fi + AUTOSSH_PIDFILE="${AUTOSSH_USER_RUN_DIR}/${prog}-${AUTOSSH_SESSION}.pid" + AUTOSSH_LOGFILE="${AUTOSSH_USER_RUN_DIR}/${prog}-${AUTOSSH_SESSION}.log" # Checking current session is already up if status_of_proc -p ${AUTOSSH_PIDFILE} $prog > /dev/null; then @@ -139,10 +142,10 @@ sleep 2 log_action_begin_msg "Creating connection for session [${AUTOSSH_SESSION}]" for e in AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT AUTOSSH_PIDFILE; do export $e; done - SSH_PARAMS="-C -o StrictHostKeyChecking=no -fN -p${AUTOSSH_RPORT} ${AUTOSSH_RUSER}@${AUTOSSH_RHOST} $(for c in ${AUTOSSH_SOCKS}; do echo -n "-D ${AUTOSSH_SOCKS_HOST}:$c "; done)" - SSH_PARAMS_REMOTE="$(for c in ${AUTOSSH_CONNECTIONS_REMOTE}; do echo -n "-R $c "; done)" - SSH_PARAMS_LOCAL="$(for c in ${AUTOSSH_CONNECTIONS_LOCAL}; do echo -n "-L $c "; done)" - start-stop-daemon --start --quiet --oknodo --chuid ${AUTOSSH_LUSER} --pidfile ${AUTOSSH_PIDFILE} --exec ${exec} -- ${SSH_PARAMS_REMOTE} ${SSH_PARAMS_LOCAL} ${SSH_PARAMS} + SSH_PARAMS="-o StrictHostKeyChecking=no -fCN $(for c in ${AUTOSSH_SPORT}; do echo -n "-D ${AUTOSSH_SHOST}:$c "; done) ${AUTOSSH_RUSER}@${AUTOSSH_RHOST} -p${AUTOSSH_RPORT}" + SSH_LPARAMS="$(for c in ${AUTOSSH_LCONNECTIONS}; do echo -n "-L $c "; done)" + SSH_RPARAMS="$(for c in ${AUTOSSH_RCONNECTIONS}; do echo -n "-R $c "; done)" + start-stop-daemon --start --quiet --oknodo --chuid ${AUTOSSH_USER} --pidfile ${AUTOSSH_PIDFILE} --exec ${exec} -- ${SSH_LPARAMS} ${SSH_RPARAMS} ${SSH_PARAMS} newretval=$? log_end_msg ${newretval} if [ ${newretval} == 0 ]; then @@ -160,9 +163,9 @@ [ -r ${config} ] || continue [ -r ${default} ] && source ${default} source ${config} - [ -n "${AUTOSSH_SESSION}" ] || continue - AUTOSSH_PIDFILE="${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER}/autossh-${AUTOSSH_SESSION}.pid" + AUTOSSH_USER_RUN_DIR="${AUTOSSH_RUN_DIR}/`id -u ${AUTOSSH_USER}`" + AUTOSSH_PIDFILE="${AUTOSSH_USER_RUN_DIR}/${prog}-${AUTOSSH_SESSION}.pid" # Checking current session is already down if ! status_of_proc -p ${AUTOSSH_PIDFILE} $prog > /dev/null; then @@ -192,7 +195,8 @@ source ${config} [ -n "${AUTOSSH_SESSION}" ] || continue - AUTOSSH_PIDFILE="${AUTOSSH_RUN_DIR}/${AUTOSSH_LUSER}/autossh-${AUTOSSH_SESSION}.pid" + AUTOSSH_USER_RUN_DIR="${AUTOSSH_RUN_DIR}/`id -u ${AUTOSSH_USER}`" + AUTOSSH_PIDFILE="${AUTOSSH_USER_RUN_DIR}/${prog}-${AUTOSSH_SESSION}.pid" status_of_proc -p ${AUTOSSH_PIDFILE} $prog "${service} for session [${AUTOSSH_SESSION}]" && retval=0 done