I'll try to be as detailed as possible.

I try to connect to a server running ActiveMQ and want to forward the port 8161 to port 8162 on my local machine in order to prevent problems when I run a local instance of ActiveMQ on my machine.

But to Access the ActiveMQ server I have to first connect to the management server which provides me with access to the network.

On both the management and the ActiveMQ server are my public key for authentication on those servers using my private key.

I am using Pageant in order to not always having to type in the password for the private key.

Path: Local Machine -> Management Server -> ActiveMQ server

Since I have to administrate and monitor many other servers this way, I wrote a batch script to access all those server directly with my private key. So naturally I would want to do this by using a script. On the other hand my colleagues only occasionally connect to some of those servers and want to use a GUI - in this case PuTTY - to access them.


Port forwarding through jumpserver (SV_B) for port 8161 on target server (SV_C) to local machine (LM) on port 8162 using private key to authenticate on both SV_B and SV_C by using PuTTY on both CLI and GUI.

LM:8162 -> SV_B -> SV_C:8161


I got the GUI part working:

  • Session: Hostname/IP address = [Management Server]; Port = "22"
  • Connection->Data: Auto-login username = "root"
  • Connection->SSH: Remote command = "ssh -L 8162:localhost:8161 [AMQ Server]"
  • Connection->SSH->Auth: Allow agent forwarding
  • Connection->SSH->Tunnels: Source port = 8162; Destination = localhost:8162

The question now is how do I translate that into a command that I can use in a script with the putty.exe

1 Answer 1


Okay, so I finally got the command to work:

plink.exe -ssh -A -L 8162:localhost:8162 root@SV_B ssh -L localhost:8162:localhost:8161 root@SV_C

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .