Setting Direct Ethernet Cable Connection between Two Ubuntu 22.04 PCs using SSH
This article will guide you through the process of setting up a direct Ethernet cable connection between two Ubuntu 22.04 PCs, and using SSH (Secure Shell) to securely access one computer (let's call it the "client") from the other (let's call it the "server").
Prerequisites
- Two computers running Ubuntu 22.04
- An Ethernet cable to connect both computers
Connecting the Ethernet Cable
Connect both computers using the Ethernet cable. Plug one end of the cable into the Ethernet port of the "server" and the other end into the Ethernet port of the "client".
Configuring Network Settings
On both computers, you need to configure the network settings manually to set a static IP address. We will use the following IP addresses:
- Server: 192.168.0.1
- Client: 192.168.0.2
To set a static IP address, follow these steps on both computers:
- Click on the network icon in the top right corner of the screen.
- Click on
Wired Connectedand thenWired Settings. - Click on the gear icon next to the network interface.
- Switch to the
IPv4tab. - Select
Manualfrom the dropdown menu. - Add the following IP address settings:
- Address: 192.168.0.1 (server) or 192.168.0.2 (client)
- Netmask: 255.255.255.0
- Click on
Applyto save the changes.
Enabling SSH Server
On the "server", you need to enable the SSH server. Follow these steps to enable the SSH server:
- Open a terminal.
- Install the OpenSSH server by running the following command:
- Start the SSH server by running the following command:
- To ensure the SSH server starts automatically at boot time, run the following command:
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl enable ssh
Connecting to the Server using SSH
On the "client", you can now connect to the "server" using SSH. Follow these steps to connect to the server:
- Open a terminal.
- Run the following command to connect to the server:
- Replace
userwith your username on the server. - When prompted, enter your password for the server.
ssh [email protected]
- Step 1: Connect both computers using an Ethernet cable.
- Step 2: Configure the network settings on both computers.
- Step 3: Enable the SSH server on the server.
- Step 4: Connect to the server using SSH on the client.