Software & AppsOperating SystemLinux

How To SSH between two different networks?

Ubuntu 10

In today’s interconnected world, the ability to securely access your computer or server from a remote location is essential. Secure Shell (SSH) is a protocol that allows you to do just that. But what if you need to SSH between two different networks? This article will guide you through the process using various methods such as port forwarding, NGROK, VPN and SSH, and port forwarding with dynamic DNS.

Quick Answer

SSH between two different networks is possible using methods such as port forwarding, NGROK, VPN and SSH, and port forwarding with dynamic DNS. These methods allow you to securely access your computer or server from a remote location by configuring network settings, using tunneling services, establishing a VPN connection, or utilizing dynamic DNS services.

Port Forwarding on Home Router

Port forwarding is a technique that redirects a communication request from one address and port number to another while the packets are traversing a network gateway. Here’s how you can set it up:

  1. Access your router’s settings: This can usually be done by typing your router’s IP address into a web browser. The specific IP address and login information can typically be found in your router’s manual or on the manufacturer’s website.
  2. Configure port forwarding: Look for a section labeled “Port Forwarding”, “Applications”, “Gaming”, or something similar. Here, you’ll want to add a new rule to forward port 22 (the default SSH port) to the specific IP address of your home PC (e.g., 192.168.1.106).
  3. Test the setup: Once port forwarding is set up, you can SSH from your office PC to your home PC using the public IP address of your home network (e.g., XXX.YYY.ZZZ.254). The command would look like this: ssh username@XXX.YYY.ZZZ.254.

Using NGROK

NGROK is a fantastic tool that allows you to expose a local server behind a NAT or firewall to the internet. It’s perfect for situations where you don’t have access to router settings or can’t set up a VPN. Here’s how to use it:

  1. Install NGROK: Download and install NGROK on your home PC.
  2. Expose your port: Run the command ngrok tcp 22 in your terminal. This tells NGROK to tunnel all TCP traffic on port 22 to the outside world.
  3. Connect to your home PC: NGROK will provide you with a unique URL that you can use to SSH from your office PC to your home PC. The command would look like this: ssh username@0.tcp.ngrok.io -p [given-port].

VPN and SSH

A Virtual Private Network (VPN) extends a private network across a public network, allowing users to send and receive data across shared or public networks as if their computing devices were directly connected to the private network. Here’s how to set it up:

  1. Set up a VPN connection: This involves configuring your home PC, office PC, and a server (e.g., a DigitalOcean droplet) to establish a VPN network. Tools like Tinc can be used to achieve this.
  2. SSH over VPN: Once the VPN is established, you can SSH from your office PC to your server and then SSH from the server to your home PC.

Port Forwarding on Router with Dynamic DNS

Dynamic DNS (DDNS) services allow you to associate a dynamic IP address with a static hostname. This is useful if your home network’s public IP address changes frequently. Here’s how to set it up:

  1. Configure port forwarding: Similar to the first method, you’ll need to set up port forwarding on your router.
  2. Set up a DDNS service: Use a DDNS service like dyn.com or noip.com to create a hostname that will always point to your home network’s public IP address.
  3. SSH using the hostname: With port forwarding and DDNS set up, you can SSH from your office PC to your home PC using the DDNS hostname. The command would look like this: ssh username@yourhostname.com.

In conclusion, SSH’ing between two different networks is a straightforward process once you understand the steps involved. Whether you choose to use port forwarding, NGROK, a VPN, or DDNS will depend on your specific needs and network setup.

What is SSH?

SSH stands for Secure Shell. It is a cryptographic network protocol that allows secure remote access and control of a computer or server over an unsecured network.

Why is SSH important?

SSH is important because it provides a secure way to access and manage remote systems. It encrypts the data exchanged between the client and server, preventing unauthorized access and protecting sensitive information.

Can I SSH between two different networks without port forwarding?

Yes, you can use alternative methods like NGROK, VPN, or Dynamic DNS to SSH between two different networks without port forwarding. These methods provide different ways to establish a secure connection between the networks.

What is port forwarding?

Port forwarding is a technique that allows network traffic to be redirected from one port on a network gateway to another port on a different device. It is commonly used to enable SSH access from outside networks by forwarding the SSH port to the specific IP address of the target device.

How do I find my router’s IP address?

You can typically find your router’s IP address by checking the documentation provided by the router manufacturer or by looking for the default gateway IP address on your computer’s network settings.

Can I use NGROK to SSH into my home PC from anywhere?

Yes, NGROK allows you to expose a local server behind a NAT or firewall to the internet, including SSH services. By using NGROK, you can SSH into your home PC from anywhere, as long as you have the NGROK software installed and configured correctly.

What is a VPN?

A VPN, or Virtual Private Network, is a technology that creates a secure, encrypted connection between a user’s device and a private network over a public network, such as the internet. It allows users to securely access and transmit data as if they were directly connected to the private network.

Do I need a server to establish a VPN connection for SSH?

Yes, to establish a VPN connection for SSH, you typically need a server that acts as the VPN gateway. This server facilitates the secure communication between your office PC and your home PC by establishing the VPN tunnel.

What is Dynamic DNS?

Dynamic DNS (DDNS) is a service that allows you to associate a dynamic IP address (which can change over time) with a static hostname. It ensures that your home network’s public IP address is always accessible using a fixed hostname, even if the IP address changes.

Can I use SSH with a Dynamic DNS hostname?

Yes, with port forwarding and Dynamic DNS set up, you can SSH into your home PC using the Dynamic DNS hostname instead of the IP address. This allows you to access your home PC even if its public IP address changes.

Leave a Comment

Your email address will not be published. Required fields are marked *