How to generate ssh keys

Share this post on:

Hello there! In this short article I want to show you how to generate fresh ssh keys and copy them to your server for passwordless login. You’ll need a Linux machine to follow through.

First step is to generate the keys. I don’t advise to use a passphrase for the private key, you’ll be asked for it every time you login to the server, which is not ideally.

$ ssh-keygen -f ./id_rsa
$ ls
id_rsa  id_rsa.pub

Here we have generated a private and a public key. Just keep them safe and don’t share with unauthorized persons!

Now the second step is to copy the public key to your server. Replace {user} and {host} with your machine credentials. When prompted, type your credential password for the user you supplied.

$ ssh-copy-id -i id_rsa.pub {user}@{host}

After this step is completed, it’s time to test the connection:

$ ssh -i id_rsa {user}@{host}

You should now be granted access without password. Please note that in this tutorial I saved the key separately but you can choose to save it to your home folder and thus to avoid using the -i shitch. Hope it’s useful to you!

Thanks for reading, I hope you found this article useful and interesting. If you have any suggestions don’t hesitate to contact me. If you found my content useful please consider a small donation. Any support is greatly appreciated! Cheers  😉

Hi there 👋
It’s nice to meet you.

Sign up to receive useful content in your inbox, every month.

Spam is a waste of time, I prefer something creative! Read the privacy policy for more info.

Author: afivan

Enthusiast adventurer, software developer with a high sense of creativity, discipline and achievement. I like to travel, I like music and outdoor sports. Because I have a broken ligament, I prefer safer activities like running or biking. In a couple of years, my ambition is to become a good technical lead with entrepreneurial mindset. From a personal point of view, I’d like to establish my own family, so I’ll have lots of things to do, there’s never time to get bored 😂

View all posts by afivan >