SSH to a computer in a local network
It is possible to take control of a computer using SSH (Secure Shell) in a local network. Local network means of two or more end devices are connected by LAN or Wifi directly without any intermediate device. There is a way to access a machine remotely where port forwarding is necessary. Today we will see how two computers can be connected and a client computer can take the system control of a server computer.
Server computer: This is the computer which will be accessed.
Client computer: This computer will access the server computer.
In my setup, I used virtual machine to create a server computer and my host computer will act as a client.
Update the database of the server computer.
sudo apt update
Install the SSH server with the following command
sudo apt install openssh-server
Check the status whether the SSH is running or not with the following command. It says the status is active and running.
sudo systemctl status ssh
Let's install net-tools for ifconfig to run for finding the ip address using the following command
sudo apt install net-tools
To check the IP address, ifconfig command is placed
We are done to setup the server side. Now it's turn for client side. Our host computer is also Unix based so we can directly use ssh command. For windows users, use the tool putty for ssh.
In MacOS, ssh server-username@ipaddress command is needed to take control of server.
You need to put "yes" for the first time to take control.
The connection established
All the files of server are accessible from client computer.
To stop ssh in server, use the following command
sudo systemctl stop ssh
Check the systemctl status for ssh. Now it is inactive and inaccessible from the client computer.