-2

My Current SSH Situation.

I got a few SSH Clients and an SSH Server. I deploy an autosshserver.script to the clients. The script creates a reverse SSH tunnel (plus it forwards port 22 and 5900) to the server. On the other side I can connect via the server to the clients.

My Problem is now, controlling the ports, that are already used by the clients. I'm looking for an way, to specify those PORT_Variables on the Server. So I can always deploy the same script, but change the ports to be used on the Server side in the authorizedkeys for example.

Those are the relevant snippets from the autosshscript.

##### VARIABLES ###########################################   

PORT_SSH="{{  PORT_SSH  }}"
PORt_VNC="{{  PORT_VNC  }}"

AUTOSSH="/usr/bin/autossh"

AUTOSSH_PARAMS="-M 0 -f -2 -4 -N -C -n -T -p $HOST_PORT"

AUTOSSH_ADV_PARAMS="-o \"ServerAliveInterval 30\" -o \"ServerAliveCountMax 2\" -o \"ExitOnForwardFailure yes\" -o \"PubkeyAuthentication yes\" -o \"PasswordAuthentication no\" -o \"UserKnownHostsFile /dev/null\" -o \"StrictHostKeyChecking no\""

LOCAL_USER_KEYFILE="-i /home/FOOSSH/.ssh/id_rsa"

TUNNEL="-R 0.0.0.0:$(PORT_SSH):127.0.0.1:22 -R 0.0.0.0:$(PORT_VNC):127.0.0.1:5900"

HOST_LOGIN_USER="FOOSSH"

HOST_NAME="ssh.FOOSSH.eu"

##### LOGIC ###############################################
su -l $LOCAL_USER -m -c "$AUTOSSH \
$AUTOSSH_PARAMS \
$AUTOSSH_ADV_PARAMS \
$LOCAL_USER_KEYFILE \
$TUNNEL \
$HOST_LOGIN_USER@$HOST_NAME" 

Thanks for help in advance. :)

1
  • It seems there is no such function. So my solutions is, to create a script.
    – grerrg
    Jun 24, 2015 at 11:49

1 Answer 1

0

So here is the solution. Not for using an SSH Build in function but by creating a workaround script.

Algorithm of the script:

  • diff <(current pub key lokal) <(pub key on server side) and read the comment, which defines the port that will be used to by the tunnel.
  • write variable into the autossh script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .