In this article i will be explaining how we can connect to a remote server using the Open SSH (Secured Shell) protocol.
But before that, we will be getting some basic command checks out of the way.
First, we check the client PC to ensure the SSH directory is currently empty.
ls -latr ~/.ssh
Output
Step 1:
Generate the SSH key pair (SSH used the asymmetric cypher for encryption)
sudo ssh-keygen
Output
If you noticed the above image, the SSH key pair was created in the /root/.ssh/ directory.
Checking the directory to see the files generated.
sudo ls -ltar /root/.ssh
Output
We are done with the client Configuration, SSH on the client has now been installed
On to the Server now
Step 2:
Install the Open SSH Server software on the Server itself.
sudo apt install openssh-server -y
Step 3:
Now we need to send/transfer the public key on the client computer to the Server using the command (utility tool on the client ssh) on the client:
sudo ssh-copy-id -i /root/.ssh/id_rsa.pub username@serverIPAddress
sudo ssh-copy-id -i /root/.ssh/id_rsa.pub afeez@192.168.1.163
You can use the
ifconfig
command to check the IP address of the server
The public key will now be transferred into the server.
To confirm this, run the command on the server.
ls -ltar ~/.ssh
Output
To confirm the public key is the same you can run a cat command on both files
Final Step:
Connect to the remote server using the command:
ssh username@remoteserverIP
ssh afeez@192.168.1.163
Output
And BOOM!!!!
We are now connected to the Sever using SSH.
I hope this helps.
Top comments (0)