Gads

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

Leave a Reply

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