Published in


Setting up SSH Authentication in Remote Server

Figure 1: Image reference for SSH Authentication

What is SSH authentication and why do you need it?

SSH Authentication is a type of authentication to any accessible server or files with the help of private and public encrypted key pairs. The private key from the user device validates with the public key pair in the remote server to authenticate and access the remote server.

Preference for SSH authentication is primarily focused on security as it provides better cryptographic strength than passwords. Furthermore, it allows users to implement single sign-on across the SSH servers they connect to.

Setting up SSH authentication:

In the remote server

  1. First login to your server manually using the password and then generate the ssh keys pair:
ssh-keygen -t rsa
Figure 2: Generating new SSH key pair using ssh-keygen

2. Copy the public key pair in the authorized_keys file

mv new_ssh_key new_ssh_key.pub .ssh //if required
cd .ssh
cat new_ssh_key.pub >> authorized_keys

In local device (from which you want to access the server):

  1. Pull private key from the server using SCP into your .ssh folder
scp <ubuntu_user>@<ip_address>:<full_address_to_ssh_key> ./.ssh

2. Add details in the config file:

Get inside the .ssh folder and create a config file.

cd .ssh
touch config
nano config

Include this in your config file:

# Remote Server
Host <remote_server_name>
HostName <server_ip_address>
User <server_user>
IdentityFile ~/.ssh/new_ssh_key

Hint: server_ip_address = and server_user = develop

3. Set up the file permission for the private key so that the key cannot be accessed by other users on your system.

chmod 600 new_ssh_key

4. Check to verify if the ssh keys are properly set up

ssh <remote_server_name>

Additional tip: You can also disable the password-based authentication in the server and only use ssh authentication to make it more secure. Also, it is wiser to remove the private key from the server to prevent any sort of unauthorized access in the future.




Visionary Development Team. We ❤︎ Technology!

Recommended from Medium

Social Media Security — Do’s and Don’ts

5D Core of GemBlock

DNS was listed on the biggest crypto analysis data platforms — Coinmarketcap and CoinGecko.

W-2 Scams, Spear Phishing, and the End of One-Size-Fits-All Security Awareness


{UPDATE} Top Movie Star Planet Makeover Hack Free Resources Generator

CRODO.IO Ambassador Program

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rohit Shrestha

Rohit Shrestha

Javascript Developer from the Himalayas

More from Medium

How to run Minikube with Podman

Install WordPress with Docker Nginx Reverse Proxy to Apache with SSL

Easily Create VMs for Docker Swarm Development

Checking for vulnerabilities in Python with Safety