How to use JProfiler over two-hop SSH tunnel

心已入冬 提交于 2019-12-08 02:41:28

问题


I'm trying to connect JProfiler to a JVM running on a server that I'll call remote. This server is only accessible from my workstation (local) via another server that I'll call middle. My plan for connecting JProfiler to remote was this:

  1. Install the JProfiler instrumentation on remote

  2. Establish SSH tunnel from local, through middle, to remote:

    ssh -v -N -L 8849:[remote's private address (192.168... etc)]:8849 [middle]

  3. Establish a new JProfiler session on localhost:8849, choosing "Startup immediately, connect later with JProfiler GUI"

However, I end up getting an error:

Connection error

Either an old version of the native library is used or another application is listening on port 8849. Please check your DYLD_LIBRARY_PATH environment variable and your port configuration

I don't have any other programs bound to local port 8849, aside from my SSH tunnel, and I have confirmed that the SSH tunnel itself should be working correctly - I'm able to forward connections for a test HTTP server from remote to local via a similarly configured tunnel.

I found this similar question, but no solution was provided.

What am I missing from my configuration?


回答1:


A direct tunnel is established with

ssh -t user@remote -L [localPort]:localhost:[remotePort] -N

A 2-hop tunnel is built with chained ssh commands:

ssh -t user@middle -L [localPort]:localhost:[remotePort] \
ssh -t user@remote -L [remotePort]:localhost:[remotePort] -N

where localPort is the port you want to use locally, and remotePort is the port that the profiling agent is listening on. All of this is executed in a single command on your local machine. More hops can be added with additional ssh calls like in the first line. There must by exactly one trailing -N for the entire command.

This approach works with JProfiler.

If the tunnels fails or if the profiling agent is not listening, you will get the message that you mentioned because of the way that the connection fails in the case of an SSH tunnel.



来源:https://stackoverflow.com/questions/27138011/how-to-use-jprofiler-over-two-hop-ssh-tunnel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!