Setting Direct Ethernet Cable Connection between Two Ubuntu 22.04 PCs for SSH

Abstract: Configure static IPs and enable SSH on two Ubuntu 22.04 PCs connected directly via Ethernet to establish a local remote access link without routers or DHCP.

Created: 2026-08-03 by

To establish a direct Ethernet connection between two Ubuntu 22.04 PCs for SSH, assign static IPv4 addresses to both machines on the same subnet, ensure the OpenSSH server is active on the host, and connect via the client using the standard ssh command with the target IP address. This method bypasses routers and DHCP servers, creating a local link that requires no external network infrastructure.

Physical Connection and Interface Identification

Begin by connecting the two computers using a standard Cat5e or Cat6 Ethernet cable. Modern network interface cards (NICs) support Auto-MDIX, which automatically detects and corrects crossover requirements, so a standard straight-through cable works for almost all modern hardware without needing a specialized crossover cable. Once physically connected, identify the network interface names on both systems using the ip addr show command. Look for interfaces that are not lo (loopback) and typically start with en (for Ethernet) or eth. Note these names, as they will be used in the configuration steps below. It is common for one interface to be named enp3s0 on one machine and enp0s31f6 on another; do not assume they share the same name.

Configuring Static IP Addresses

Since there is no DHCP server present on a direct cable link, you must manually assign IP addresses to both machines. Using NetworkManager, which is the default networking tool in Ubuntu 22.04, you can create a new connection profile for the specific interface. On the machine acting as the SSH server, open a terminal and run nmtui (Network Manager Text User Interface). Select "Edit a connection," choose your Ethernet interface, and modify it. Set the IPv4 Configuration to "Manual." Assign an IP address such as 192.168.1.10 and a netmask of 255.255.255.0 (/24 prefix). Save the connection and bring it down and up again to apply changes. Repeat this process on the second machine, which will act as the SSH client. Configure the same interface with a manual IPv4 setting, but use a different IP address in the same subnet, such as 192.168.1.20, with the identical netmask 255.255.255.0. Do not set a gateway for either machine since they are communicating directly. After configuring both IPs, verify connectivity by pinging from one machine to the other. Run ping 192.168.1.20 from the first machine. If you receive replies, the physical layer and IP configuration are correct. If the ping fails, check the interface status with ip link to ensure the state is UP rather than DOWN.

Enabling the SSH Server

Ubuntu Desktop editions do not always have the SSH server enabled by default, whereas Ubuntu Server editions enable it automatically. To check if the SSH service is running on the target machine, execute systemctl status sshd. If the service is inactive or not installed, install it using sudo apt update && sudo apt install openssh-server. Once installed, enable and start the service with sudo systemctl enable --now sshd. You should see output indicating that the service is active and running. It is important to note that while some guides suggest modifying firewall rules extensively, UFW (Uncomplicated Firewall) on Ubuntu typically allows incoming SSH traffic if the rule exists. By default, UFW may block incoming connections. To allow SSH, run sudo ufw allow ssh. This command opens port 22 for incoming TCP connections. There is no need to configure outbound ICMP or complex routing tables for a direct link. Ensure that the firewall is enabled with sudo ufw enable if it was previously disabled, as leaving the firewall off is a security risk even on a local link.

Establishing the SSH Connection

With the server configured and the client having a valid IP, initiate the connection from the client machine. Open a terminal and type ssh [email protected], replacing username with the actual user account name on the server machine. The first time you connect, you will see a message asking to verify the host's authenticity. Type yes to add the server’s key to your known hosts file. You will then be prompted for the password of the remote user. Enter the password carefully; characters will not appear on screen for security reasons. Upon successful authentication, you will see the remote shell prompt, confirming that the direct Ethernet SSH connection is working. If you encounter a "Connection refused" error, verify that the SSH service is actually listening on port 22 using ss -tlnp | grep :22. If you get a "Permission denied" error, double-check the username and password. For enhanced security, consider setting up SSH keys to avoid password prompts in the future, though this is optional for basic access.

Troubleshooting Common Issues

If the connection still fails after verifying IPs and services, check the following areas. First, ensure that both machines are on the exact same subnet. A mismatch like 192.168.1.x vs 192.168.2.x will prevent communication. Second, check for any active VPNs or virtual network adapters on the client machine that might intercept the traffic. Disable any non-essential virtual networks temporarily. Third, verify that the Ethernet interface is not set to "Automatic" in NetworkManager settings, which might attempt to grab a lease from a router if one becomes available later, potentially overwriting your static config. Finally, consult related resources for broader networking context, such as Connecting to Ubuntu using ssh over Ethernet, which covers similar foundational concepts for remote access.

Frequently Asked Questions

Do I need a crossover cable for this setup?

No, modern network interfaces support Auto-MDIX, which automatically adjusts the pinout for direct connections. A standard straight-through Ethernet cable is sufficient for connecting two Ubuntu 22.04 PCs directly.

Why can't I ping the other computer after setting IPs?

Check if the firewall is blocking ICMP packets. While UFW usually allows SSH, it might drop pings if custom rules are active. Verify the interface is UP with ip link and ensure no other network managers are interfering with the connection.

Is it safe to leave SSH open on a direct link?

Yes, a direct Ethernet link isolates the traffic from the public internet. However, always use strong passwords or SSH keys. Avoid logging in as root unless necessary, and keep the system updated to patch potential vulnerabilities.

What if I forget the SSH password?

You cannot recover a forgotten Linux password remotely via SSH. You would need physical access to the server machine to reset the password using recovery mode or by booting from a live USB drive to modify the /etc/shadow file.

Can I transfer files without SSH?

While SSH provides a secure channel for file transfer using SCP or SFTP, you could also use simple HTTP servers or rsync over the direct link. However, SSH remains the most secure and standard method for both command execution and file management in this scenario.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More