Wrapper around SSH to establish a secure OSI layer 3 tunnel
- Shell 89.4%
- Makefile 10.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| bin | ||
| examples | ||
| Makefile | ||
| README.md | ||
SSH-VPN
SSH is versatile. Using the -w option SSH can even establish secure
connections between tun (OSI layer 3) or tap (OSI layer 2) devices.
This project helps setting up and maintaining a VPN tunnel based on a SSH connection.
Installation
- Setup SSH to connect to your VPN endpoint:
- Create a key pair.
- Place the public key in the endpoint's
~root/.ssh/authorized_keys. - Enable
PermitTunnelin the endpoint's SSH server config.
- Test the SSH connection manually (as root, because the SSH client
needs to create a local tunX device:
should connect and create a tunX device on the remote host.ssh -w any <remote host> - Install this SSH VPN scripts and Systemd unit files:
make install - Copy
examples/ssh-vpn@example.comas/etc/default/ssh-vpn@<name of your tunnel>. - Edit
/etc/default/ssh-vpn@<name of your tunnel>. I strongly recommend using IPv6 forLOCAL_IPandREMOTE_IP. This avoids clashes with existing IP addresses. A good starting point to get a more or less uniq IPv6 ULA address is this ULA address generator. - Enable the Systemd Unit:
systemctl enable ssh-vpn@<name of your tunnel> - Start ths tunnel:
systemctl start ssh-vpn@<name of your tunnel>
Technical background
The command ssh -w any remote.example.com establishes a SSH connection
as usual, from your local machine to the remote host. While you may be
familiar with SSH's port forwarding options (-L, -R), here SSH
creates tun devices on both ends. Tun device behave like normal network
device for OSI layer 3 (IP).