Pejman Moghadam / Debian

Debian 10 - Internet access through SSH

Public domain


Scenario

Server: A machine with SSH server that you can connect from Client, but does not have Internet access.
Client: A machine with SSH access to server and has Internet access.
Objective: Provide Internet access to Server through Clients SSH tunnel.


Server: add to /etc/ssh/sshd_config and restart ssh service

PermitTunnel yes

Client: connect to server

ssh root@192.168.1.10 -p22022 -w0

Client: router settings

ifconfig  tun0 1.1.1.1 netmask 255.255.255.0
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE

Server: Gateway settings

ifconfig  tun0 1.1.1.2 netmask 255.255.255.0
ping -c 4 1.1.1.1
route add -net <client network> gw <old gateway>
route del default
route add default gw 1.1.1.1

BY: Pejman Moghadam
TAG: ssh, sshdconfig
DATE: 2021-05-26 01:20:35


Pejman Moghadam / Debian [ TXT ]