diff --git a/networking/dynamic-ssh-forwarding.md b/networking/dynamic-ssh-forwarding.md new file mode 100644 index 0000000..9dc1240 --- /dev/null +++ b/networking/dynamic-ssh-forwarding.md @@ -0,0 +1,36 @@ +## Set up port forwarding + +1. Set up port forwarding + ```bash + $ ssh -D 8080 -N ubuntu@mercurial-manfifold.eu + ``` +2. Try out connection + ```bash + $ curl --socks5 127.0.0.1:8080 http://example.com + ``` + +## Set system-wide proxy configuration + +1. Create `/etc/profile.d/proxy.sh` with the following content: + ```bash + #!/bin/bash + + if [ -f "/etc/proxy-enabled" ]; then + export http_proxy="127.0.0.1:8080" + export https_proxy="127.0.0.1:8080" + export ftp_proxy="127.0.0.1:8080" + export HTTP_PROXY="127.0.0.1:8080" + export HTTPS_PROXY="127.0.0.1:8080" + export FTP_PROXY="127.0.0.1:8080" + export no_proxy="localhost,127.0.0.1,::1" + export NO_PROXY="localhost,127.0.0.1,::1" + fi + ``` +2. Add the following to `.zshrc`: + ```bash + alias proxy-on='sudo touch /etc/proxy-enabled' + alias proxy-off='sudo rm -f /etc/proxy-enabled' + ``` + +Note that enabling or disabling the proxy only takes effect after logging out +and back in, as that is when `/etc/profile.d/proxy.sh` is sourced.