SSH (Secure Shell) is a cryptographic network protocol that allows secure communication between two devices over an unsecured network. It is commonly used to establish a secure remote connection to a server or device. In this article, we will guide you on how to set up an SSH connection with three Ubuntu machines to bypass a firewall.
Prerequisites
Before we begin, make sure you have the following:
- Three Ubuntu machines connected to the same network.
- Administrative access to all three machines.
Step 1: Install OpenSSH Server
The first step is to install the OpenSSH server on the machine you want to connect to. Follow these steps:
- Open a terminal on the machine where you want to install the OpenSSH server.
- Run the following command to install the OpenSSH server:
sudo apt update sudo apt install openssh-server
This will install the OpenSSH server on your machine.
Step 2: Configure Firewall
In order to bypass the firewall, we need to allow incoming SSH connections. Follow these steps to configure the firewall:
- Open a terminal on the machine where the firewall is configured.
- Run the following command to allow incoming SSH connections:
sudo ufw allow ssh
This will allow incoming SSH connections through the firewall.
Step 3: Find IP Addresses
In order to establish an SSH connection, we need to know the IP addresses of the machines involved. Follow these steps to find the IP addresses:
- Open a terminal on each Ubuntu machine.
- Run the following command to find the IP address:
ip addr show
Look for the IP address under the network interface you are connected to. Note down the IP addresses of all three machines.
Step 4: Connect to Remote Machine
Now that we have installed the OpenSSH server, configured the firewall, and found the IP addresses, we can establish an SSH connection. Follow these steps:
- Open a terminal on the machine from which you want to connect to the remote machine.
- Run the following command to connect to the remote machine:
ssh username@ip_address
Replace "username" with the username of the remote machine and "ip_address" with the IP address of the remote machine.
You will be prompted to enter the password for the remote machine. Once you enter the correct password, you will be connected to the remote machine via SSH.
Step 5: Copy SSH Keys
Entering a password every time you want to establish an SSH connection can be cumbersome. To avoid this, you can copy your SSH keys to the remote machines. Follow these steps:
- Open a terminal on the machine from which you want to copy the SSH keys.
- Run the following command to generate SSH keys:
ssh-keygen
Press Enter to accept the default location and passphrase (leave it empty).
- Run the following command to copy the SSH keys to the remote machine:
ssh-copy-id username@ip_address
Replace "username" with the username of the remote machine and "ip_address" with the IP address of the remote machine.
You will be prompted to enter the password for the remote machine. Once you enter the correct password, your SSH keys will be copied to the remote machine.
Step 6: Test SSH Connection
To ensure that the SSH connection is working properly, follow these steps:
- Open a terminal on the machine from which you want to test the SSH connection.
- Run the following command to connect to the remote machine:
ssh username@ip_address
Replace "username" with the username of the remote machine and "ip_address" with the IP address of the remote machine.
If the SSH connection is successful, you will be connected to the remote machine without entering a password.
Congratulations! You have successfully set up an SSH connection with three Ubuntu machines to bypass a firewall. Now you can securely access and manage your remote machines without any restrictions imposed by the firewall.
| References |
|---|
| 1. Ubuntu OpenSSH Server Documentation |
| 2. How To Set Up SSH Keys on Ubuntu 20.04 |
| 3. SSH Academy |