I have a remote server that only exposes SSH. It has services running on other ports, for example a database on port 3306. These ports cannot be accessed remotely, but are accessible from within the server context (localhost:3306).

Using ssh -L I can access a single port on the remote server. But how can I make all these ports accessible to my local machine over an ssh/sshuttle connection?


On the remote server define a secondary IP address, for example, that points to itself. (The same way does.)

On your local machine, create your sshuttle connection as follows:

sshuttle -r user@remote
# "user" is your username on the remote machine
# "remote" is the name or IP address of the remote machine

You can now access the remote server at the address. Because it understands connections from to be "itself", all the ports are accessible at that address. (They stop being accessible as soon as you close the sshuttle connection.)

You can confirm this with the following commands:

nmap remote # returns only ssh port
nmap # returns all ports

You can now connect to your database with the address For example, if it's a MySQL database you can connect to it uing MySQL Workbench.

If this approach suits you, you may want to investigate using sshoot to manage your sshuttle connections.

  • "user" is your user on the remote machine and "remote" the IP or name of the remote server? And this allows you to connect with (for instance) workbench to the remote server? – Rinzwind Jul 13 '17 at 15:13
  • @Rinzwind yes! I've updated the answer to clarify – david.libremone Jul 14 '17 at 12:50

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.