SSH as socks proxy through multiple hosts
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Beneath the City Looping
--
Chapters
00:00 Ssh As Socks Proxy Through Multiple Hosts
00:44 Accepted Answer Score 43
01:51 Answer 2 Score 2
02:30 Thank you
--
Full question
https://superuser.com/questions/332850/s...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ssh #proxy #sshtunnel #socksproxy #socks
#avk47
ACCEPTED ANSWER
Score 43
Three slightly different methods. (Replace $PORTX and $PORTY with port numbers of your choice.)
First method: ProxyCommand
machine-a$ ssh -f -N -D $PORT -oProxyCommand="ssh -W %h:%p machine-b" machine-c
Second method:
Connect from A to B, with "local forwarding" of
$PORT
tolocalhost:$PORT
.machine-a$ ssh -L $PORT:localhost:$PORT machine-b
Connect from B to C, with "dynamic forwarding" enabled.
machine-b$ ssh -f -N -D $PORT machine-c
Configure your browser to use proxy at
localhost:$PORT
.
Steps #1 and #2 can be summarized to:
ssh -f -L $PORT:localhost:$PORT machine-b "ssh -f -N -D $PORT machine-c"
Third method:
Connect from A to B, with "local forwarding" of
$PORTX
tomachine-c:22
.machine-a$ ssh -f -N -L $PORTX:machine-c:22 machine-b
Connect from A to C over the tunnel, with "dynamic forwarding".
machine-a$ ssh -f -N -D $PORTY localhost -p $PORTX
(You can omit
-f -N
if you want to use the same tunnel for interactive connections too.)Configure your browser to use proxy at
localhost:$PORTY
.
ANSWER 2
Score 2
For AWS EMR Sock Proxy, below are the applied steps. Assuming we have two hops scenarios as below
[your-laptop] --<ssh key1>--> [Jump-Box] --<ssh key2>--> [EMR-Master]
And you have already setup FoxyProxy in your browser. Active it before starting the before starting the steps.
Step 1. Login to Jump Box
ssh -i ~/.ssh/key1 ec2-user@
Step 2. Setup dynamic tunnel on the Jump box, assuming Key2 is present there.
ssh -i ~/key2 -N -D 8157 hadoop@
Step 3. Open a fresh console on the ssh client and set up tunnel.
ssh -i ~/.ssh/key1 -L 8157:localhost:8157 ec2-user@ -N