How to debug a ssh tunnel

2019-03-28 05:29发布

I want to setup a simple ssh tunnel from a local machine to a machine on the internet. I'm using

ssh -D 8080 -f -C -q -N -p 12122 <username>@<hostname>

Setup works fine (I think) cause ssh returs asking for the credentials, which I provide.

Then i do

export http_proxy=http://localhost:8080 and wget http://www.google.com

Wget returns that the request has been sent to the proxy, but no data is received back. What i need is a way to look at how ssh is processing the request....

1条回答
Melony?
2楼-- · 2019-03-28 06:08

To get more information out of your SSH connection for debugging, leave out the -q and -f options, and include -vvv:

ssh -D 8080 -vvv -N -p 12122 <username>@<hostname>

To address your actual problem, by using ssh -D you're essentially setting up a SOCKS proxy which I believe is not supported by default in wget.

You might have better luck with curl which provides SOCKS suport via the --socks option.

If you really really need to use wget, you'll have to recompile your own version to include socks support. There should be an option for ./configure somewhere along the lines of --with-socks.

Alternatively, look into tsock which can intercept outgoing network connections and redirecting them through a SOCKS server.

查看更多
登录 后发表回答