0

I am trying to set up an SSH tunnel into a small Lubuntu server that I have created, and I am unsure about how to actually find the IP address that I will use to connect to it from my laptop. The SSH service is 100% running on the server. I have total root access to the server, so I can find anything that I need.

I have found numerous resources online, but with all of them, as soon as I type "ssh USERNAME@IP_ADDRESS" (filling in the information obviously) the terminal just creates a blank new line and nothing happens past that, so I assume that I am using the wrong IP. The server is connected via Ethernet to a different network as my laptop is connected to via WiFi.

I have tried using the IP address from ifconfig, but that doesn't work. I have tried using the public ip address from "curl ipinfo.io/ip" and that didn't work either.

Any help would be appreciated.

  • Hi, welcome to Stack Overflow! Can you describe the networks involved? It sounds to me like the server is on a network behind a router, and your laptop is on a different network. I imagine you're trying to SSH in through the router to the server. Is that accurate? – Klaatu von Schlacker Feb 6 at 19:23
  • @KlaatuvonSchlacker Yeah, that is pretty much the gist of it. The server is connected directly to the router, and my laptop is on a different network via WiFi. I would like to ssh through the router, yes. – Produces Feb 6 at 19:26
0

You need to enable NAT ("port fowarding") on your router.

How this is done differs from router to router, unfortunately. You must log in to your router and search for whatever mechanism its embedded OS uses to send traffic from one port (22, for instance) to a specific IP on your network.

In your case, you want to forward traffic from port 22 (the default SSH port) to the internal IP address (the one you obtained from ifconfig or ip addr) on port 22 of your server.

Some routers call it NAT or Port Forwarding. Others call it "Applications" (because gamers often have to use this feature to play games across networks), others call it something different entirely.

Once you've done that, use the public IP address (the one you get from sites like http://icanhazip.com) of the server (it's actually the IP of the router itself). When you SSH to your router at its public IP address, it knows (because you've configured it in the NAT settings) to forward traffic at port 22 to the server IP address. Once you authenticate, your server lets you in.

Once you have that set up and are comfortable with it, you should look into implementing fail2ban for better security.

Here's an example of what a common router interface looks like (but yours will almost certainly be different).

Router example

  • Ok great, will do. Once I've done that, which IP would I use to ssh from my laptop? – Produces Feb 6 at 19:42
  • I've edited my answer to explain. – Klaatu von Schlacker Feb 6 at 19:52
  • Maybe you could use a Switch device or put them side-by-side in the network or client downwards of the server. Already tried to do this NAT thing here but hadn't success, only with Switch device or client machine downwards of server machine. – Vasconcelos1914 Feb 6 at 20:13
  • Upwards and downwards we means connect client device WAN in LAN port of server device. – Vasconcelos1914 Feb 6 at 20:23

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.