I'm trying to SSH tunnel hop to a Tomcat7 server where JMX was configured on port 9090.

Essentially: localhost > hostB > hostC.

In a terminal, from localhost to hostB:

ssh -L 8989:localhost:8989 me@hostB

Once connected to hostB, I'll enter the following command to connect to hostC:

sudo -u userA ssh userB@hostC -i /path/to/key -p 21559 -L 8989:localhost:9090

In VisualVM, I attempt to connect to localhost:8989 but get "Cannot connect to localhost:8989 using service:jmx:rmi...".

The configuration of Tomcat/JMX is the same as the other servers located inside the firewall. Those were previously confirmed accessible with VisualVM.

All commands work without the forwarding of ports. I'm able to interact with hostC without any issues. I simply cannot tunnel at this point.

Update #1

Using netstat from hostC:

[userB@hostC ~]$ netstat -an | grep 8989
[userB@hostC ~]$ netstat -an | grep 9090
tcp        0      0 :::9090           :::*                        LISTEN 

With a terminal looking like this:

[userB@hostC ~]$ 

In another terminal, I entered the following:

telnet localhost 8989
Connected to localhost.
Escape character is '^]'

Seems like it's connected?


It should work fine, assuming you are not observing any errors with ssh. I would test with telnet to port 8989 and also look at netstat -an for listening connections and make sure you see connections being established all the way

  • Once connected to hostB, netstat -an | grep 8989 should return something? In my case, nothing is returned. No errors in terms of SSH. – TekiusFanatikus May 19 '15 at 18:42
  • On hostC you should see connections on 8989 and what does telnet to localhost:8989 give? – VenkatC May 19 '15 at 19:22
  • I've added update #1 with the details you asked for – TekiusFanatikus May 19 '15 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.