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.

puma
  • 21
  • 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 https://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
  • @Nmath is a home network, I aimed to be able to remote access files from the server, Is there a better and/or safer solution than ssh, and couldn't I just expose port 23, or use a VPN? – puma Jul 10 '21 at 18:41
  • 3
  • First make sure that your ISP does not put you behind CGNAT or whether you can use IPv6. – FedKad Jul 10 '21 at 18:48
  • @user68186 I can access the computer fine on LAN, its remote access that is my issue. – puma Jul 10 '21 at 18:50
  • 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
  • Remote access issues are not Ubuntu related problems. These can be due to your ISP's settings that you can't change, as well as your router settings which you can change. However, your router settings are off-topic here. – user68186 Jul 10 '21 at 18:54
  • @user68186 thanks, I'll go look at a networking StackExchange – puma Jul 10 '21 at 18:57
  • Also see the When Traveling section of this answer for some hints on port forwarding and DDNS. – user68186 Jul 10 '21 at 18:59
  • 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

1 Answers1

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.

raj
  • 10,353