Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to trouble shoot a certain issue on the server, but I could not connect my debugger since the person who maintains the firewall is off on a vacation. I dont want to mess with his settings. He has given me admin password though.

So for my purpose I need to attach a debugger to a Java program running on the server. When I do "jdb -attach port" on the server via ssh it works. I want to use eclipse in my machine to connect to that port. So this is what I think is the best thing to do in my situation.

Run a program listening on the server, run a program on my machine and make them talk thru SSH. Then my eclipse will connect to the local program which will talk to the servers local application which will attach me to the JVM process. (Profit!!!:)

I am not sure how to do this. I have a vague idea that I should be using netcat. But can you please help me with how to launch netcat or any other program for this purpose on both ends.

Your help is greatly appreciated. Thank You.

share|improve this question
+1 for the new title ;) – Mark Henderson Dec 21 '09 at 3:49
The new title is terrible, it completely fails to describe the nature of the problem. – womble Dec 21 '09 at 4:13
True, but I wasn't sure if the old title contained a suggestion for a solution, I wasn't sure if I should be suggesting the solution since I did not have a lot of clue. So I made it generic. But it is bad in that it sure does not give any more information. Thanks for your solution womble. – Senthil Dec 21 '09 at 10:20
up vote 5 down vote accepted

To open a port 12345 on your local machine that, when connected to, will connect to a port 54321 on remotemachine (the machine you're SSH'd into):

ssh -L 12345:localhost:54321 remotemachine
share|improve this answer
The remote port 54321 is already bound and the debugger server is listening on it. When I issue this command I get "port already bound" message. – Senthil Dec 21 '09 at 16:28
SSH doesn't bind on the remote port, it tries to connect to it. Something else is going on here; output of ssh -vvv -L 12345:localhost:54321 remotemachine might help. – womble Dec 21 '09 at 19:22
I found these two switches helpful. -f and -N ssh -f user@remote -L 54321:localhost:12345 -N – Senthil Dec 23 '09 at 17:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.