Connect via ssh to one of the multiple clients on same network
Solution 1:
You need to create port forwarding rules in your router's settings, for each device in the local network.
For example you can crate:
- rule, where router's port 1110 is redirected to port 22 (this is the standard SSH port) of the device in the local network, which has local IP 192.168.1.110, and
- rule, where router's port 1115 is redirected to port 22 of the device with local IP 192.168.1.115.
Let's assume, your router has public IP address 77.60.52.10, so you will be able to connect to the device with local IP address 192.168.1.110 via this command:
ssh [email protected] -p 1110
Also, you will be able to connect to the device with local IP address 192.168.1.115 via:
ssh [email protected] -p 1115
Here you are, an example for port forwarding on TP-LINK home router:
EDIT: Home routers usually have UPnP configuration interface. In Ubuntu, you can create port forwarding (mapping) through this interface with some tool like UPnP PortMapper.
It is a good idea to set up static IP addresses for the devices in your local network. One of the ways to do that is through address reservation page in the router's setting:
EDIT: Assignment of static IP could be done also through the configuration of the OS. Here's an example of how to do this in:
- Ubuntu Server
- Ubuntu Desktop
Further reading:
- How to create a restricted SSH user for port forwarding?
- How to SSH on a port other than 22
- Help Ubuntu: Network Configuration