I have a home network setup behind a NAT router with two linux boxes. Occasionally, I want to ssh to them from outside the home network, but neither have a public IP address. What's your recommendation?

Currently, I have setup a dynamic DNS record for the router, which reroutes all remote connections to one server. If I do want to ssh to the other server, I first ssh to the first server, and then ssh from the first to the second.

Is there an option to connect to either of the servers directly through ssh tunneling or virtual domains and such?

link|improve this question

78% accept rate
feedback

3 Answers

up vote 9 down vote accepted

You can always port forward and use a separate port for each machine. In /etc/ssh/sshd_config Change the line that says:

port 22

to whatever you wish. Different for each machine obviously. You could use 22222 for one and 22223 for the other. Then you can run ssh -p 22222 user@1.2.3.4 for example, or within PuTTY change the port.

Make sure to restart the sshd service after changing this so it re-reads the configuration file

link|improve this answer
feedback

Easiest would be to change the port SSH listens to on the internal network, and forward those IPs to the correct internal box.

link|improve this answer
feedback

The router should be programmed too.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.