There is an Ubuntu 16.04 server running a service/daemon that listens only to 127.0.0.1. A second Ubuntu 16.04 server needs to query this service/daemon found only on the first server.
Is there a way to do this? Will an SSH tunnel work?
There is an Ubuntu 16.04 server running a service/daemon that listens only to 127.0.0.1. A second Ubuntu 16.04 server needs to query this service/daemon found only on the first server.
Is there a way to do this? Will an SSH tunnel work?
Yes, a ssh tunnel will do this for you.
Assume remote service is listening on localhost:2345
and you want to be able to access it at your localhost:4321
, and your username on the remote machine is remoteuser
and the remote machine's hostname is remotehost
ssh -L4321:localhost:2345 remoteuser@remotehost
This says "connect as remoteuser to remotehost via ssh, and tunnel traffic from my port 4321 on localhost (no ip specified on local side) to port 2345 on whatever remotehost resolves as localhost (localhost is specified) "
Another example, forwarding through remotehost
to some website on port 80 -
ssh -L3456:www.example.com:80 remoteuser@remotehost
This is "tunnel traffic from port 3456 on my localhost to port 80 on whatever remotehost resolves as www.example.com". You could then point a browser to http://localhost:3456 and see the content of www.example.com
HTH