Skip to content

Instantly share code, notes, and snippets.

@allen-munsch
Created October 24, 2019 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allen-munsch/39da966282207984f62dae239ffd5f51 to your computer and use it in GitHub Desktop.
Save allen-munsch/39da966282207984f62dae239ffd5f51 to your computer and use it in GitHub Desktop.
ssh socksv5 tunnel example for firefox

SSH SOCKv5 tunnel for firefox, etc.

https://gist.github.com/allen-munsch/63c2071103cbb04cbd82d10a47baf67e

on ssh server

nano /etc/ssh/sshd_config 
PermitTunnel yes
service ssh restart

on local machine

ssh -C -N your-host.com -vvv -D 8001
sudo ss -tulpn | grep 8001

firefox config

# assumes 1 default profile "*.default"
if [[ "$OSTYPE" == "darwin"* ]]; then
  export FFPROFILE=/Users/$USER/Library/Application\ Support/Firefox/Profiles/*.default/
else
  export FFPROFILE=$HOME/.mozilla/firefox/profiles/*.default
fi

export CURRENTIP=$(curl ifconfig.co)
echo current $CURRENTIP

sed -i 's/user_pref("network.proxy.socks", ".*");/user_pref("network.proxy.socks", "localhost");/g' $FFPROFILE/prefs.js
sed -i 's/user_pref("network.proxy.socks_port", .*);/user_pref("network.proxy.socks_port", 8500);/g' $FFPROFILE/prefs.js
sed -i 's/user_pref("network.proxy.type", .*);/user_pref("network.proxy.type", 1);/g' $FFPROFILE/prefs.js
sed -i 's/user_pref("network.proxy.no_proxies_on", .*);/user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");/g' $FFPROFILE/prefs.js
sed -i 's/user_pref("network.proxy.socks_remote_dns", .*);/user_pref("network.proxy.socks_remote_dns", true);/g' $FFPROFILE/prefs.js


export PROXYIP=$(curl ifconfig.co -x localhost:8001)
echo proxy $PROXYIP

disable proxy in ff

if [[ "$OSTYPE" == "darwin"* ]]; then
  export FFPROFILE=/Users/$USER/Library/Application\ Support/Firefox/Profiles/*.default/
else
  export FFPROFILE=$HOME/.mozilla/firefox/profiles/*.default
fi
sed -i 's/user_pref("network.proxy.type", .*);/user_pref("network.proxy.type", 0);/g' $FFPROFILE/prefs.js

~/.ssh/config

Host your-host.com
    User root
    IdentityFile ~/.ssh/your-host.rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment