Skip to content

Instantly share code, notes, and snippets.

@skaag
Created March 24, 2015 14:02
Show Gist options
  • Select an option

  • Save skaag/6696b3d4a50f5d8fc830 to your computer and use it in GitHub Desktop.

Select an option

Save skaag/6696b3d4a50f5d8fc830 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Some config params:
device_id=$(hostname | tr -cd "[:digit:]" )
device_port=$((22000+$device_id))
vnc_port=$((25000+$device_id))
remote_port=23456
host_addr=1.2.3.4
host_user=skaag
exec >/dev/null
exec 2>&1
exec /usr/bin/ssh -T -N -C \
-o BatchMode=yes \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o IdentitiesOnly=yes \
-o ConnectTimeout=10 \
-o ConnectionAttempts=3 \
-o port=$remote_port \
-i /root/.ssh/id_dsa \
-R $device_port:localhost:22 \
-R $vnc_port:localhost:5900 \
$host_user@$host_addr < /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment