How to create an SSH Keys?

This instructions help you to make an SSH key using ssh-keygen -t rsa

Sometimes it is useful to be able to log in an SSH-server without a password. For instance when you have automated pipelines doing some work. How do we create the key?

How to make the SSH-key?

Create a RSA key, using the following command
ssh-keygen -t rsa
You will see the following prompt
Generating public/private rsa key pair.
Enter file in which to save the key (.ssh/id_rsa)
Fill in your key name, please avoid using the default names so you won't overwrite any older keys. We are using danielknows in this example
Enter file in which to save the key (/Users/admin/.ssh/id_rsa): danielknows
Enter passphrase (empty for no passphrase):
We don't want to add a passphrase if we want to login without user interaction, just press enter.
Enter same passphrase again: 
Your identification has been saved in danielknows
Your public key has been saved in danielknows.pub
The key fingerprint is:
SHA256:randomstringhere [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|.xo  ..          |
|o..o*  x         |
|=+o= =...        |
|*.o + o..        |
| o o ooxS        |
|x = .ox* .       |
|+* . .+ +        |
|=x..   * .       |
|..o...x.+        |
+----[SHA256]-----+
After creating the keys, put the public key (danielknows.pub) in the remote make inside the .ssh/authorized_keys folder
After setting the key on the remote machine, you can use the private key to setup a connection, but first make sure the permissions are both ok:
chmod 400 danielknows
ssh -i danielknows [email protected]
Now you are logged in into the remote machine, without using a password. This freshly generated private key is being used for the login
by Daniel at 2023-04-02T18:18:31.274Z
Copyright © DanielKnows.com 2019 - 2023 - Built with NuxtJS