Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cathal
Created November 13, 2016 17:42
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 cathal/1b38b770fff5904d41f869aaf778a9b9 to your computer and use it in GitHub Desktop.
Save cathal/1b38b770fff5904d41f869aaf778a9b9 to your computer and use it in GitHub Desktop.
SOCKS Proxied SSH
# append the following to bash profile
# ~/.bash_profile or #~/.bashrc
export PATH="$PATH:~/bin"
#!/bin/sh
# ~/bin/ssh-socks
# USAGE: ssh-proxy USERNAME@HOST
# : ssh-proxy -i ~/.ssh/id_rsa.private_key USERNAME@HOST
curl -sSf --socks5-hostname localhost:5678 www.google.com > /dev/null || status=$?
if [[ $status -ne 0 ]]; then
echo "No SOCKs proxy is open on port 5678. Open it first!"
echo "You can open a SOCKs proxy with SSH using:"
echo " ssh -D 5678 USERNAME@HOST"
exit 1
fi
ssh -o ProxyCommand='nc -x localhost:5678 %h %p' $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment