I needed to be able allow a friend to browse the internet from my ISP to see something, so I figured how how to use a socks proxy with ssh and windows. Putting the whole thing in here.
First we are going to exchange the ssh keys
C:\Users\steve>ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\steve/.ssh/id_ed25519):
Created directory 'C:\\Users\\steve/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\steve/.ssh/id_ed25519
Your public key has been saved in C:\Users\steve/.ssh/id_ed25519.pub
C:\Users\steve>type .ssh\id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+7oHHAmyY2CJqpmw4GVgsoL6Lzd7dPcVYsrR6TeJmD steve@D2024
now we copy that to the linux server “.ssh/authorized_keys” (make sure the permission on .ssh and authorized_keys is good – that will cause issues)
we need the ssh server to allow the forwarding to listen on 0.0.0.0 instead of 127.0.0.1
vi /etc/ssh/sshd_config
GatewayPorts clientspecified
systemctl restart ssh
next we run the ssh. this one lets something on the other side to this side
ssh -R *:8080 <IP/HOST>
this one lets you browse from the other side
ssh -D *:8080 <IP/HOST>
then you need to set up the browser/windows
or you can use powershell
$proxyAddress = "127.0.0.1"
$proxyPort = "8080"
function Enable-Proxy {
# Registry path for Internet Settings
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
Set-ItemProperty -Path $regPath -Name ProxyServer -Value "socks=$proxyAddress:$proxyPort"
# Optional: Set bypass list for local addresses
# Set-ItemProperty -Path $regPath -Name ProxyOverride -Value "localhost;127.0.0.1;<local>"
Write-Host "Proxy enabled: socks=$proxyAddress:$proxyPort"
}
function Disable-Proxy {
# Registry path for Internet Settings
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0
Write-Host "Proxy disabled"
}
function Toggle-Proxy {
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$currentStatus = Get-ItemProperty -Path $regPath -Name ProxyEnable
if ($currentStatus.ProxyEnable -eq 1) {
Disable-Proxy
} else {
Enable-Proxy
}
}