Share your PC’s Internet to the Ubuntu Server through SSH

Best case: your PC can SSH into the Ubuntu server

Run this on your PC:

ssh -N -R 127.0.0.1:1080 ubuntu_user@UBUNTU_SERVER_IP

This creates a SOCKS proxy on the Ubuntu server at:

127.0.0.1:1080

Traffic from the Ubuntu server will go through SSH and exit from your PC’s internet connection.

On the Ubuntu server, test it:

curl --proxy socks5h://127.0.0.1:1080 https://ifconfig.me

Other case: Ubuntu server can SSH into your PC

Then run this on the Ubuntu server:

ssh -N -D 127.0.0.1:1080 pc_user@PC_IP
curl --proxy socks5h://127.0.0.1:1080 https://ifconfig.me

More reliable option: use an HTTP proxy through SSH

Run an HTTP proxy on your Windows PC

For example, if you already use one of these apps:

App Common HTTP / mixed proxy port
v2rayN 10809 or similar
Clash Verge / Clash for Windows 7890
NekoRay / NekoBox usually configurable

Use the app’s HTTP or mixed proxy port.

ssh -N -R 127.0.0.1:1080:127.0.0.1:7890 ubuntu_user@UBUNTU_SERVER_IP

 

Create an SSH User with a non-interactive Shell

Create the Restricted System User

sudo useradd -r -s /bin/false -m -d /home/proxyuser proxyuser

Set Up Authentication

sudo passwd proxyuser

Configure SSH Daemon

sudo nano /etc/ssh/sshd_config
Match User proxyuser
    AllowAgentForwarding no
    AllowTcpForwarding yes
    X11Forwarding no
    PermitTTY no
    ForceCommand /bin/false

Restart the SSH Service

sudo systemctl restart ssh
# or
sudo systemctl restart sshd