How to create an ssh or secure shell on your server

SSH is an encrypted protocol used to administer and communicate with servers. When working with a linux server, chances are you will spend most of your time in a terminal session connected to your server through SSH. In this guide, we’ll focus on setting up SSH keys for a Linux installation. SSH keys provide a secure way of logging into your server and are recommended for all users.

Why Is SSH Used?

Secure Shell (SSH for short) is a network communication protocol that makes it possible for two computers to communicate with one another. SSH also makes data transfers possible between two computers.

Create a user in Linux

adduser arif
 update-alternatives --config editor
//chose default editor as a NANO
visudo 

SSH key generate

at first, you would have to create a key on your local computer using GitBush. Remember it is not your live server. it would be creating our own computer that you use. after creating the key then we will transfer the key to the live server. Let’s start…

ssh-keygen -t rsa -b 4096
ssh-copy-id -i /c/Users/emran/.ssh/id_rsa.pub [email protected]

//comment: click 2 time for skip file location and passpharase.
//ssh-copy-id -i <ssh file location> <Live_server_username@ip>
//comment: write your own file location path and your server user and ip like mine. Follow the screenshot

SSH configuration

Now we have to configure the sshd_config file. there are all the ssh configuration options are given.

nano /etc/sshd/sshd_config

after run this command a text editor will be visible. now we would have to uncomment and config some of the options from there. follow the screenshot

  • PermitRootLogin no
  • PubkeyAuthentication yes
  • PasswordAuthentication no
sudo systemctl restart ssh

the change we made is not active. after run “sudo systemctl restart ssh” command our all the configurations will be active.

Login Using SSH key

Open the new CMD from windows and write a following way that i have given in the screenshot below

ssh -i .ssh/id_rsa [email protected]
// ssh -i <key file location> <liveserver_username@ip> 

Leave a Reply

Your email address will not be published. Required fields are marked *