1

I have two laptops, one running Ubuntu (server) and another running Debian (client), and I want to use ssh to log in to the shh server. While on my router's network, using the private IP address of the server works fine. However, as soon as I leave the network (client), such as connecting to my phone's hotspot or using some other network with internet access, I can no longer connect, using either the public or private IP. The service being used to connect is openssh.

11
  • We do not support debian. If you want questions regarding the CLIENT side and "However, as soon as I leave the network, such as connecting to my phone's hotspot or using some other network with internet access" I would assume to be from the client then please use unix.stackexchange.com for your question.
    – Rinzwind
    Jul 10 '21 at 18:29
  • 2
    I'm your assuming the server laptop is on your home network. You can't ssh into a server on your home network unless you're either on your home network or you have a dedicated IP address or dynamic DNS from your ISP and you expose your home network to the internet. Don't expose your home network this way unless you are absolutely confident in your ability to secure your network. Even for someone who is not a novice, it's not a very good idea. Instead consider renting a server or a VPS.
    – Nmath
    Jul 10 '21 at 18:32
  • 3
    Does this answer your question? Connect two computers with SSH in a home LAN
    – user68186
    Jul 10 '21 at 18:46
  • 4
    When you could connect properly on the LAN, you conclusively demonstrated that your Ubuntu server is properly configured and operating. After that, your problem is getting through your router, which has nothing to do with Ubuntu. Look up how to use the port forwarding feature on your router.
    – user535733
    Jul 10 '21 at 18:53
  • 1
    ssh itself is safe, but opening up your home network is not so safe. Depending on what services you need to access remotely, it might be a better idea to get a VPS or dedicated server hosting
    – Nmath
    Jul 10 '21 at 19:07
2

By design, if you have a LAN behind a NAT router, it is not possible to connect from outside to inside your LAN. Private addresses have no meaning outside your LAN (that's why they are called "private") and using the public address, you will connect to your router only and not to any machine inside your LAN. As @user535733 has pointed out, you need to set up port forwarding on your router so that the router knows that connections to a particular port (say, ssh port) on the router should be forwarded to a particular machine inside your LAN. This has nothing to do with Ubuntu or Debian itself and you have to check your router's documentation on how to do that.

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.