Creating SSH Keys (Article)

This short tutorial is the first of a series dedicated to those who might want to get familiar with the blockchain platform Decbc. This first tutorial is a step-by-step guide to get your setup: you will learn how to create your SSH keys for your computer. 

What is SSH?

The SSH protocol is a method of securely connecting computers over the internet. It offers a variety of strong authentication options and uses strong encryption to ensure the confidentiality and integrity of communications. It’s a safe alternative to unreliable file transfer methods and unprotected login protocols (like telnet and rlogin) (such as FTP).

1. Preparing the SSH 

First you open a command line from your computer, each operating system has its own way on how to open a command line. If you are using Windows 10 you can find the command line under ‘PowerShell’ on the start menu, if you are using Ubuntu Linux the easiest way to directly open the command line is by entering the combination of the Ctrl+Alt+T key. In the OSX you can find the command line on the finder, then find ‘Terminal’. 

Graphical user interface, application

Description automatically generated

Now that we’ve found the command line, let’s see our current location on the directory using command 

$ pwd

to see what files are contained in this directory we do command:

$ ls -alsh 

This allows us to see folders and files that are normally visible and invisible; those that are hidden usually start with . (dot).

The folder that we are interested in is the folder .ssh, you may not have it in your computer if you never created the key before as we get inside the folder, so don’t worry. 

In this computer, it has already been created and already has some keys. You can see the content by using command:

$ cd .shh

To list all the content of this folder type: 

$ ls -alsh 

As you can see there are two key pairs; one for the rsa algorithm and one for the ed25519 algorithm.  Now I’m going to delete everything and let’s pretend my .ssh directory doesn’t exist and let’s start anew. 

I will remove it in a recursive way by using command:

$ rm -r .ssh

Now that it’s gone,  the folder .ssh is no longer there when I recheck it, so let’s move and start our tutorial on creating your own SSH now. 

2. Installing the SSH 

Let’s move into our first step of SSH installation. To create the SSH, you need to create a directory by using command:

$ mkdir .ssh

Now that you’ve created the .ssh directory in your computer, if you check using ls -alsh you can see that the ssh directory has already existed.

Our next step is to create the ssh keypair. “Ssh-keygen “is to create the ssh keypair, the “-t” is to specify the type of the key and because we’re gonna create the rsa key, it’s gonna be: 

$ ssh-keygen -t rsa 

After you press enter, it will now ask you where to save the.ssh directory, it has already chosen the directory because that’s its default place. 

But in some cases you have to create it manually, both ways press enter after you’ve finished creating / choosing where to save it. 

And now it asks whether you want to use a password, so every time you need to use the key it will ask for the password. However, as this tutorial is for learning purposes only, I will leave this field blank and press enter

Finally the rsa key has been created. To re-check, go to the directory using command cd .ssh, then ls -alsh. If you see the rsa keys are inside the file then we did it right. 

If you look closer you can see there are 2 files. The is the public key, you can share it with anyone that wants to authenticate your computer, for example the hosting provider. Meanwhile, the id_rsa is your private key. Never share it with anyone. 

To see the content of the key I can use the command:

$ less id_rsa .pub

Once you get inside the file, you can see a sort of blob of data, and we need this when we install our VPS which is a virtual private server. Press “Q ” to get out and go back to the previous menu. 

After we’ve finished creating a key for the rsa, let’s have an experiment for a different key, for example an ed25519 which is based on a curve. 

First let’s type the command:

$ ssh-keygen -t ed25519 

If you look closely it has a similar process like we did earlier; you choose where you want to save it. Click enter if you agree with the place where they want to save it. Then choose your password or you can leave it blank like I did, and press enter.

Now if we go into the directory you can see 2 new files of id_ed25519  that we just created.

And we try to look inside the file with command:

$ less id_ed25519 .pub 


Description automatically generated

You can see that the string is way smaller compared to the previous one, because the algorithm doesn’t require a long set of bytes to make it safe.

And Finally, 

At this point, there’s no more reason you couldn’t create your own SSH key! You can also follow the step-by-step instruction through our YouTube tutorial 1: How to create SSH keys