Home > linfati.cl > auto-connect to ssh vpn using upstart

auto-connect to ssh vpn using upstart

if you have a ssh keys configured to root user in a ssh-server, you can do a vpn over ssh using a tun interface

copy the text to /etc/init/vpn2ssh.conf, change 1.2.3.4 for the ip of the vpn server and do “start vpn2ssh”

# vpn2ssh - vpn over ssh to ssh server manager
#
# vpn over ssh to ssh server manager

description "vpn over ssh to va.linfati.cl manager"
author "Rodrigo Linfati <rodrigo@linfati.cl>"
version "0.1"

start on started gdm
stop on stopping gdm

respawn
expect fork

env vpnserver=1.2.3.4
env idtun=309
env iplocal=172.30.9.2
env ipremote=172.30.9.1

pre-start exec sleep 60
exec ssh -C -f -w $idtun:$idtun $vpnserver ifconfig tun$idtun $ipremote pointopoint $iplocal  up
post-start exec                            ifconfig tun$idtun $iplocal  pointopoint $ipremote up

Note: on ssh server need “PermitTunnel=yes” on sshd_config

Categories: linfati.cl Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.