1

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.

  • 2
    +1 for the new title ;) – Mark Henderson Dec 21 '09 at 03:49
  • 5
    The new title is terrible, it completely fails to describe the nature of the problem. – womble Dec 21 '09 at 04: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. –  Dec 21 '09 at 10:20

1 Answers1

5

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
womble
  • 96,255
  • 29
  • 175
  • 230
  • 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. –  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 –  Dec 23 '09 at 17:01