0

I have a remote host 123.456.789 that I am able to SSH into. From within the SSH host, a private database host can be accessed.

I would like to forward my local port on my computer TO the private database host via the remote host (using it as a bastion - if this is the correct terminology).


I'm trying to do:

ssh 3306:my-private-host-database.example:3306 example@123.456.789
ssh: Could not resolve hostname 3306:my-private-host-database.example:3306: Name or service not known

So the issue seems to be that my-private-host-database.example resolves correctly only on the internal dns of the bastion 123.456.789 host.

Is this possible to be done?

5
  • 1
    3306:my-private-host-database.example:3306 seems the argument to a -L or -R options. Without one of them, it is probably just parsed as hostname in a simple ssh hostname (the whole expression, including the two 3306 and the colons). Are you trying to set up some port forwarding? Or to simply connect to a private host through a bastion? – fra-san Jul 16 '20 at 14:39
  • Thanks sorry, that was a typo :) - I did have a -L in there. – Chris Stryczynski Jul 16 '20 at 14:43
  • 1
    Still strange. When you connect to 123.456.789, it doesn't immediately try to also establish a connection to the -L's argument. You shouldn't get any error. In other words, ssh port:unreachable_host:port working_user@working_host gives no error (then, trying to connect to the local port would time out). Are those really the commands you are running and the error you are seeing? – fra-san Jul 16 '20 at 14:51
  • Hmmm you're correct.. Let me double check this. – Chris Stryczynski Jul 16 '20 at 14:53
  • 1
    Yup seems you're correct! I was just missing the -L argument. Thank you! Feel free to post this as an answer. – Chris Stryczynski Jul 16 '20 at 14:55
1

(Based on a troubleshooting session we had in comments)

In

ssh 3306:my-private-host-database.example:3306 example@123.456.789

the string 3306:my-private-host-database.example:3306 seems to be the argument to a missing -L or -R option. Without the option, that whole string is taken as a host name (including the two 3306s and the colons).

Since you are trying to set up a local port forwarding, that command should likely be

ssh -L 3306:my-private-host-database.example:3306 example@123.456.789

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.