To connect to an Ubuntu machine via SSH over Ethernet, you must first ensure the SSH server is installed and running on the target system. Next, identify the local IP address assigned to the Ethernet interface and verify that port 22 is accessible from your client device. Finally, initiate a connection using the standard SSH command syntax with the remote user’s credentials to establish a secure terminal session.
Installing and Configuring the SSH Server
The foundation of any remote access setup involves ensuring the necessary software is present on the Ubuntu host. By default, many minimal installations of Ubuntu do not include the OpenSSH server package. You can install it by opening a terminal on the Ubuntu machine and executing the following commands:
sudo apt update
sudo apt install openssh-server
Once the installation completes, the service should start automatically. You can verify its status by running
systemctl status ssh. If the service is active and running, you are ready to proceed. It is crucial to ensure that the firewall allows incoming connections on port 22. On Ubuntu systems using UFW (Uncomplicated Firewall), you can enable this rule with
sudo ufw allow ssh. This step prevents common connectivity issues where the server is running but blocked by security policies.
Identifying the Network Interface and IP Address
Since you are connecting over Ethernet, you need to determine the specific IP address assigned to your wired network interface. Unlike Wi-Fi interfaces which may change names or have different configuration methods, Ethernet interfaces typically follow a predictable naming convention such as
eth0 or
enp3s0. You can view all network interfaces and their associated IP addresses by using the
ip addr show command. Look for the inet value under the Ethernet interface section.
If you are unsure which interface corresponds to your Ethernet cable, look for the one that has a valid IPv4 address and is marked as UP. Avoid using loopback addresses like 127.0.0.1, as these only refer to the local machine itself. Once you have identified the correct IP address, write it down or keep the terminal window open for reference. This IP address serves as the destination for your SSH client. For more detailed information on how Ubuntu manages these network configurations, you might find it helpful to read about
Ubuntu server network interfaces.
Connecting from Windows or Linux Clients
With the server running and the IP address known, you can now initiate the connection from your client machine. The process is nearly identical whether you are using a Windows PC, a Mac, or another Linux distribution. Open your command prompt, PowerShell, or terminal and use the ssh command followed by the username and the IP address. The general syntax is
ssh username@ip_address.
For example, if your remote user is named "ubuntu" and the IP address is "192.168.1.50", you would type:
ssh [email protected]
Upon the first connection, you will be asked to confirm the host key fingerprint. Type "yes" to accept and add the host to your known hosts list. You will then be prompted for the password of the remote user. Enter the password carefully; note that characters will not appear on the screen for security reasons. If the credentials are correct, you will gain access to the remote shell.
If you encounter connection timeouts or refusal errors, check your physical cabling and router settings. A common issue is routing problems where the client cannot reach the subnet of the server. In such cases, reviewing troubleshooting steps for persistent SSH errors can provide clarity on network path issues, as discussed in our guide on
Persistent SSH Error 'port 22: No route to host'.
Securing Your Connection
While password authentication works, it is vulnerable to brute-force attacks. It is highly recommended to switch to key-based authentication for enhanced security. Generate an SSH key pair on your client machine using
ssh-keygen and copy the public key to the Ubuntu server using
ssh-copy-id. This allows you to log in without typing a password every time. Additionally, consider disabling password login entirely in the SSH daemon configuration file (
/etc/ssh/sshd_config) by setting
PasswordAuthentication no. After making changes, restart the SSH service with
sudo systemctl restart ssh to apply the new security policies.
Frequently Asked Questions
What if I get a "Connection Refused" error?
This error usually means the SSH service is not running on the target machine or the firewall is blocking port 22. Verify that the openssh-server is active using systemctl and ensure your firewall rules permit inbound traffic on that port.
Can I use a hostname instead of an IP address?
Yes, provided both machines are on the same local network and DNS resolution is configured correctly. You can use the local hostname if it is broadcasted via mDNS or if you have added an entry to your local hosts file.
How do I know if my Ethernet cable is working properly?
Check the link lights on the network port of both the Ubuntu machine and the router or switch. If the lights are off, try replacing the cable or moving to a different port on the switch to rule out hardware failures.
Is it safe to leave SSH enabled on my home network?
It is generally safe if you use strong passwords or key-based authentication. However, exposing SSH directly to the internet is risky due to brute-force attempts. Always restrict access to your local network or use a VPN for remote access outside your home.
What should I do if I forget the password for the remote user?
You will need physical or console access to the Ubuntu machine to reset the password. Boot into recovery mode or use a live USB to mount the filesystem and use the passwd command to set a new password for the account.