SSH VPN

Intro

I needed to have access to a network which only has a ssh access. So I used the ssh tools to set a VPN

Network diagram

Source : Archlinux

Commands

root@host:~# ssh -Nf -w 0:0 -p 22 root@1.1.1.1
root@host:~# ip addr add 10.110.0.200/32 peer 10.110.0.100 dev tun0
root@host:~# ip link set tun0 up
root@host:~# ip route add 192.168.1.0/24 via 10.110.0.100

Destination : Debian

Commands

root@host:~# apt-get install uml-utilities
root@host:~# systemctl status uml-utilities.service
root@host:~# echo 1 | tee /proc/sys/net/ipv4/ip_forward
root@host:~# ip addr add 10.110.0.100/32 peer 10.110.0.200 dev tun0
root@host:~# ip link set tun0 up
root@host:~# ip route add 192.168.2.0/24 via 10.110.0.200
root@host:~# iptables -t nat -A POSTROUTING -d 192.168.1.0/24 -o eth0 -j MASQUERADE

/etc/ssh/sshd_config

PermitRootLogin yes
PermitTunnel yes

Sources

Licence Creative Commons
This website http://shebangthedolphins.net is licensed to the public under a licence Creative Commons Attribution licence.
Contact :