You have your terminology backwards! What you are trying to do is tunnel from the local machine to the remote system. This is because the remote system is the TCP server so a connection is initiated on your local system and accepted on the remote system. The ListenForwardedPort
method is for the other direction.
I didn't test this but from my read of the Granados source code I think you want the ForwardPort
method instead. It takes four host-related arguments like this:
remote_host
: the host with the server on it, i.e. your MySQL server
remote_port
: the port the server is listening on, i.e. 3306
originator_host
: the host you want to listen on the local side, probably "localhost"
originator_port
: the port of the host you want to connect to on the local side, you can re-use 3306 or pick any other available number
Your MySQL server, the remote_host
, might be "localhost" (as seen by the other endpoint of the SSH connection) but it could also be any machine reachable by the remote system. You can also use the IP address of the remote system, i.e. something other than localhost or 127.0.0.1.