Linux

How to setup passwordless ssh connection

Setup key based ssh connection


The Secure Shell, commonly referred as ssh, is a private-public key scheme used to authenticate to remote hosts. In order to setup passwordless, key based ssh authentication, the first step is to generate two keys i.e. the private key and public key.

  1. ssh-keygen – generate RSA private and public key with 2048 bits size.


$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/daniel/.ssh/id_rsa):     [ press Enter]

2. ssh-copy-id – copy public key to the host you want to authenticate without a password


$ ssh-copy-id -i ~/.ssh/id_rsa.pub cloudclient
daniel@cloudclient's password:
Now try logging into the machine, with "ssh 'cloudclient'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

3.  ssh to remote host


$ hostname
kauai.example.net

[daniel@kauai tmp]$ ssh cloudclient

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-116-generic x86_64)
Last login: Wed May 2 00:05:59 2018 from 192.168.10.103
[daniel@cloudclient]$ hostname

cloudclient

 

References –


https://www.ssh.com/ssh/keygen/

https://www.ssh.com/ssh/copy-id

daniel

Share
Published by
daniel
Tags: rsassh

Recent Posts

GCP for Linux System administrators

Linux System Admins Journey to Google Cloud Platform As a Linux system administrator, you have…

10 months ago

Top 5 Troubleshooting Tools for Network Professionals in Linux

As a network professional, troubleshooting is a crucial part of your daily routine. To streamline…

10 months ago

netstat equivalent tool

The net-tools set of packages had been deprecated years back, although the commands are still…

2 years ago

GCP GKE – run kubectl through bastion host

Re-posting my answer to a Google cloud platform's Google Kubernetes Engine (GKE) related question in…

4 years ago

Spoof User Agent in http calls

Recently I was trying to download numerous files from a certain website using a shell…

5 years ago

Terraform – show logging

Enabling logging in terraform for debugging

5 years ago