top of page
christiandreschler9

Creating a SSH key-pair.



What is SSH?

SSH stands for Secure SHell.


The Secure Shell (SSH) protocol is a method for securely sending commands to a computer over an unsecured network. SSH uses cryptography to authenticate and encrypt connections between devices.


Why SSH?

Logging in with Username and Password is not a secure way to access a remote server, because both parameters can be easily hacked.


SSH is a more secure method for accessing remote servers (i.e. git servers).


How does it work?

The most secure way to use SSH is by using a SSH-key pair (public-key & private-key)


The public key is stored locally on your machine and generally should also be sent to the remote server.


The private key is stored locally and should NOT be shared.


If you use a key pair to access to a remote server, username and password are not required.

Both your local and remote pc will recognize themselves automatically.


How to create a SSH key-pair

This usually depends on the key type and length.


You can create a safe key-pair by opening the terminal and typing the following line

ssh-keygen -t ed25519 -b 4096 -C "insert short comment here"

where:

ssh-keygen is the command used to generate the keypair


the -t defines the type of the generated key pair and it corresponds to the algorithm used.


the -b flag defines the number of bits in the key to create.


the -C flag associate a comment to the generated keys.


The output of the above command is:

Generating public/private ed25519 key pair,

Enter file in which to save the key (/home/UserName/.ssh/id_ed25519):

where:

UserName is the username you use to log into your PC (i.e. 'john' ).


/home/UserName/.ssh/id_ed25519 is the full path of the key pair.


After the above prompt you can press ENTER to accept.


You will be asked if you want to generate a password to access your private key

Leave the field empty by pressing ENTER


The key pair is generated.


How do I use the generated key pair?

In my next post I will show how to use a key pair to safely access to your remote git repository on gitlab.com

7 views0 comments

Recent Posts

See All

Comments


bottom of page