How to connect through SSH to a device that is in the same network

stats con chris
2023-03-12
0

...

We show the steps to follow in Linux to connect through SSH to a device that is in the same network.

We show the steps to follow in Linux to connect through SSH to a device that is in the same network.

We are going to consider two devices that are part of the same network. For example, two laptops that are connected to the same router via WiFi. In Fig. 1 we depict these devices. We call them nepy and hp.

Fig. 1: Devices in the same network.

Our goal is to connect to hp using our nepy device. Notice that hp has two users, ortiz and guest, then we are going to connect to each of them. A summary of this article with some extra info appears in the following video:

The steps to follow are:

1. Install SSH server

You have to have admin rights to install SSH server. Install it in the device that you want to access remotely. In our example it is the hp device and the user with admin rights is ortiz. Then, in its terminal type:

sudo apt install openssh-server

To verify that it was properly installed go to your Settings. In Sharing, the Remote Login should be On, see Fig. 2:

Fig. 2: Settings window.

Also, you can test SSH by typing the following:

ssh 127.0.0.1

This allows you to connect through SSH from ortiz@hp to ortiz@hp. If the connection is refused, either the installation failed or you may have a firewall preventing this. If the connection is succesful, to close it press the keys Ctrl+D.

2. Get the IP

To access hp from a different device in the same network, we first need to know its IP. Type the following:

hostname -I
192.168.178.31 2001:9e7:384b:c200:6b0h:56e2:dc2e:cf1 2001:9e7:384b:c200:f2a:6638:332b:b9b5

In the output above, 192.168.178.31 is the IP.

3. SSH from a different device

Now you are ready to SSH from a different device in the same network. In this example, the second device is called nepy, recall Fig. 1. This device has the following user: ortiz@nepy. Recall that the hp device has two users: i) ortiz@hp and ii) guest@hp. Type the following in the nepy device:

ssh 192.168.178.31

The password of ortiz@hp is requested. If you type the correct password you will be connected to ortiz@hp. To go back to ortiz@nepy type Ctrl+D. Similarly, to connect to guest@hp type the following:

ssh guest@192.168.178.31

The password of guest@hp is requested. If you type the correct password you will be connected to guest@hp. Notice that in this second we specify the username. In the first case we didn't do it because nepy and hp shared the same name (ortiz). If you want to connect to a device that is not in the same network, I invite you to read the article: "How to connect through SSH to a remote device that is not in the same network."

Views: 1

stats con chris

A writer who learned to add

A writer who learned to add

Notifications

Receive the new articles in your email

2022 © nepy

One single breath

Configure

Choose your own style

Color

Choose the perfect color mode for you


Navigation Position

Select a suitable navigation system


Vertical Navbar Style

Switch between styles for your vertical navbar

Customize