Secure Shell(ssh)

Ajay Gopal Shrestha
Nov 6, 2017 · 3 min read

I have been working with authenticating a server with permission file (ssh). What I’ve learned so far covers only the surface. Here’s a short summary of my understanding.

You need to start by configuring the public key in the server where the server allows access when the user presents a valid private key. Following are the procedures I followed:

  • Secure Shell (SSH) is used everywhere for managing servers and devices.
  • Instead of insecure username and password, ssh uses secure key or SSH key pair(private and public).

Generating SSH key

The above code generates ssh key pair (private and public). If you do not specify any name for the key name, id_rsa will be generated as default: Private File: id_rsa Public File:

Adding SSH key

Connecting to remote server

Configuring server for your private key to work

You can manually add the key to authorized_keys file. For that, copy the public_key content from and paste it into new line in authorized_keys. To copy the key from command line:

linux and mac
  • Connect to the server using normal ssh command with password.
  • Go to home folder
  • Create folder .ssh
  • create file authorized_keys
  • use vi to edit the authorized_key files -> vi authorized_keys
  • paste the public key content here

You can use special command to copy the public key to a linux server

This will add the public key directly to authorized_keys file. If the file is not created, it will create it automatically

Ajay Gopal Shrestha

Written by

Sr. Software Engineer, Fusemachines Inc. Full Stack Developer. Experienced in working with PHP, javaScript, Emberjs, ReactJs, NodeJs, ExpressJs, jQuery