Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a ssh tunnel

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....

like image 968
Francis Martens Avatar asked Feb 14 '11 13:02

Francis Martens


People also ask

How do I debug SSH?

To enable SSH debug, run the SSH command with the -v, -vv, or -vvv option: In this example, you can see what a successful SSH connection would look like with the complete back and forth communication between the hosts. debug1: Connecting to 9.55. 216.115 [9.55.

How do you check SSH tunneling is working?

The simplest way to test a ssh tunnel is with the telnet command and with a python http server. For reverse connection, this would be the following. On the local, install python3 and ssh, then. >telnet localhost 8080 Trying 127.0.

How do I debug if SSH is not working?

Troubleshooting steps:Verify that the host IP address is correct. Verify the firewall rules, check the inbound rules allowed by the security group. Verify the port number allowed for ssh. Verify that the service is running properly.


1 Answers

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.

like image 91
Shawn Chin Avatar answered Oct 21 '22 16:10

Shawn Chin