SSH Password less Login Using SSH Keygen in 5 Easy Steps

SSH Client : 192.168.0.12 (Michele's Box)
SSH Remote Host : 192.168.0.11 (Frankie's Box)

In this example we will setup SSH password-less automatic login from server 192.168.0.12 as user michele to 192.168.0.11 with user frankie.

Step 1: Create Authentication SSH-Kegen Keys on — (192.168.0.12)

ssh-keygen -t rsa

Step 2: Create .ssh Directory on — 192.168.0.11

Use SSH from server 192.168.0.12 to connect server 192.168.0.11 using frankie as user and create .ssh directory under it, using following command.

ssh frankie@192.168.0.11 mkdir -p .ssh

Step 3: Upload Generated Public Keys to — 192.168.0.11

Use SSH from server 192.168.0.12 and upload new generated public key (id_rsa.pub) on server 192.168.0.11 under frankie‘s .ssh directory as a file name authorized_keys.

cat .ssh/id_rsa.pub | ssh frankie@192.168.0.11 'cat >> .ssh/authorized_keys'

Step 4: Set Permissions on — 192.168.0.11

Due to different SSH versions on servers, we need to set permissions on .ssh directory and authorized_keys file.

ssh frankie@192.168.0.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

Step 5: Login from 192.168.0.12 to 192.168.0.11 Server without Password

From now onwards you can log into 192.168.0.11 as frankie user from server 192.168.0.12 as michele user without password.

ssh frankie@192.168.0.1

Thanks for reading ✌🏻

--

--

--

Director Of Engineering at Bucksense, Inc 📈 Crypto & NFT Fan | ⌨️ Mechanical Keyboard Enthusiast | 🍕 Pizza Maker

Love podcasts or audiobooks? Learn on the go with our new app.

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
Michele Berardi

Michele Berardi

Director Of Engineering at Bucksense, Inc 📈 Crypto & NFT Fan | ⌨️ Mechanical Keyboard Enthusiast | 🍕 Pizza Maker

More from Medium

How to Install jq(JSON processor) on RHEL/CentOS

A Preliminary Study on the Configuration File of PulseAudio Sound Card

Version Control with Git

Linux kernel 2.6.* Error: “code model kernel does not support PIC mode”