Let’s say that we wanted to connect an Ethernet cable from Ethernet port of one computer to Ethernet port of another computer. I want to be able to SSH into the other machine from my computer given that I know the other machine’s password or have an authenticated SSH key.

ethernet-to-ethernet

You can also SSH to a series of machines if you have a switch with all the other machines connected to that switch through Ethernet cables. The switch is basically a hub point where all the machines can connect their Ethernet cables to and be able to access every other machine on the local area network.

ethernet-cables-to-a-switch

Let’s talk about how to SSH from 1 computer to another computer when the Ethernet cable from port to port of the two computers. One of the computers is my Windows 10 laptop. The other computer is an Ubuntu 16.04 server.

 

Step 1) Start the SSH server on the Ubuntu 16.04 computer.

First, we make sure that we have the OpenSSH server installed. We will require Internet access for this step.

sudo apt-get install openssh-server

Now, we restart the SSH server to be sure that it is working properly.

sudo service ssh restart
ssh stop/waiting
ssh start/running, process 3878

Step 2) Connect Ethernet cable from the Ethernet port of Windows 10 computer to the Ethernet port of the Ubuntu 16.04 computer.

Step 3) Set a static IP address on the Ubuntu 16.04 computer.

If both machines are connected to the Internet on the same router through Wi-Fi, then you will not need to create a static IP address. For more information about setting static IP addresses on Ubuntu, go here.

sudo vi /etc/network/interfaces

Look for an interface that begins with eth. The interface is typically named eth0.

auto eth0
iface eth0 inet static
address 18.125.5.100
netmask 255.255.255.0
gateway 18.125.5.1

Now, you save the file and restart the interface.

sudo ifdown eth0 && sudo ifup eth0

Step 4) Set a static IP address on the Windows 10 computer.

We need to have an IP address on the same IP space as the Ubuntu 16.06 computer. On Windows 10, you will right click the Internet icon on your task bar and click on Open Network and Sharing Center.

change-adapter-settings

On the right side bar, click Change adapter settings. Right click on Ethernet and click Properties. Click on Internet Protocol Version 4. Click Properties.

ethernet-properties-windows-10

Check off Use the following IP address and fill out IP address and Subnet mask. Note that you cannot use an IP address that is already used by the other machine.

internal-network-access-set-local-ip-on-machine

I will set the Windows 10 computer with the IP address 18.125.5.251 and the subnet mask of 255.255.255.0. Default gateway is optional. Use the following DNS server addresses is optional. I set 8.8.8.8 to point to Google’s Public DNS server. I check off Validate settings upon exit and hit OK.

After the validation, your computer should have the new static IP address. If you do not have Wi-Fi, you will not have Internet access at the moment since you set a static IP address that is likely not valid by your DHCP server, but you will be able to SSH into the Ubuntu 16.04 computer.

Step 5) SSH from Windows 10 terminal to the Ubuntu 16.04 computer.

For the Windows 10 terminal, you can use something like Cygwin to SSH into the Ubuntu 16.04 computer. Cygwin is program that allows Windows to use UNIX.  First, we ping the Ubuntu 16.04 machine to see if we have network connectivity.

ping 18.125.5.100

Eureka! Now, we can SSH into the Ubuntu 16.04 computer with its username.

ssh ubuntu@18.125.5.100

Enter your password, and you will have access to your Ubuntu 16.04 computer from your Windows 10 computer using the local area network and direct Ethernet cable.