Configure OpenSSH server and router to accept SSH connection over internet?

I want to access my PC from anywhere. I'm able to connect to the PC within the same LAN using the local IP. However, outside the local network I see a connection time out error.

How can I configure my OpenSSH server on Host and my router to allow SSH connections from anywhere over the internet?


Solution 1:

You need your remote Client, your home router, and your Host server to cooperate in creating an SSH connection on the same Port. Use port-forwarding within your router's configuration to forward the correct port (e.g., Port 22) to the local IP address of your Host server.

  • Port-forwarding settings should be present inside "NAT" or "Virtual Network" on the 192.168.1.1 page you use to configure your router :)
  • ifconfig on Host server will show its current local IP. Use nm-connection-editor to generate a Static IP address for this machine if it's not Static already.
  • Host server listens for SSH connection on Port listed in /etc/ssh/sshd_config