How to Create SSH Keys for Linux

How to Create SSH Keys for Linux

An SSH key is an access credential utilized for the SSH protocol. Its function is similar to that of user names and passwords, but the keys are primarily used for accessing servers via the command line.

Create SSH Key

To create and SSH key on Linux we can use the command ssh-keygen.

ssh-keygen

After pressing enter you will then be promted with the question to name the location of the file.

Enter file in which to save the key (/home/me/.ssh/mykeyname): 	
/home/me/.ssh/mykeyname

Now it is time to select a password for your SSH key. This password will be asked for when the key is utilized in the future. If you do not want a password for the key, simply leave it blank.

Enter passphrase (empty for no passphrase):
Enter same passphrase again: 

When you have finished entering your password, a public and a private key will be created.

Your identification has been saved in /home/me/.ssh/mykeyname
Your public key has been saved in /home/me/.ssh/mykeyname.pub
The key fingerprint is:
SHA256:dzE12DVnHlqX47/nukMyVkZJs6KQirNp0D4GDEjFkl0 me@fedora
The key's randomart image is:
+---[RSA 3072]----+
| .=..E       +=**|
|oo o     .  ..*O=|
|o .     o   +oo o|
| o . . . . . +o. |
|  + + . S o .o  .|
|   + +   . .+ . .|
|    B      . +  .|
|   o .        ...|
|              o=o|
+----[SHA256]-----+

The newley created key is now located in the ~/.ssh under the name the name you specified, mykeyname and mykeyname.pub.

Add SSH key to key-ring

To be able to use the SSH key we should add it to the key-ring. We can do so with the following command.

ssh-add ~/.ssh/mykeyname

To use the public key you can simply copy mykeyname.pub

cat ~/.ssh/mykeyname.pub
Freddie Freddie 2 years, 4 months ago 0
Login to Comment
No comments have been posted yet, be the first one to comment.
Create, Access and Use SSH Keys with macOS
Create, Access and Use SSH Keys with macOS
SSH or "Secure Shell" is a network protocol for operating networked services securely. It is typically used for remote command-line authentication and command execution. In this tutorial I will show you how you can create, access and use your SSH key for macOS. 1. Open Termi...
How to install NodeJS on Fedora 35
How to install NodeJS on Fedora 35
The easiest way to install NodeJS on Fedora 35 is to use the dnf package manager. Use DNF to download NodeJS Simply Open up your terminal and run the following command. sudo dnf install nodejs Verify the packages to download After you have run sudo dnf install nodejs you will have to ...
How to Install Go on Linux
How to Install Go on Linux
Download the latest Linux version of Go You can download the latest binary from https://go.dev/dl/ Extract the archive you downloaded into /usr/local, creating a Go tree in /usr/local/go. Important: This step will remove a previous installation at /usr/local/go, if any, prior to extr...