SSH Key it’s a more convenient way to guarantee security rather than just using a password to connect remotely to a device.
In this article, we’ll learn how to create an SSH Key to connect remotely to a device through senhasegura.
First, we have to create the public and private SSH keys in the server:
$ ssh-keygen -t RSA -m PEM
After the execution of the command above, some settings will be requested:
The path of where the keys will be saved.
And a passphrase, that is, the password requested when occurs the remote connection and the confirmation.
After that, the public and private keys will be created.
You can confirm the values of both SSH Keys, public (id_rsa.pub) and private (id_rsa), in the path where have been saved:
cd <keys path> cat id_rsa cat id_rsa.pub
Now, we need a folder “authorized_keys” that contains the public key value to establish a remote connection to this device:
cat id_rsa.pub >> authorized_keys
The SSH Keys creation and configurations have been done.
Now, on senhasegura, we must create SSH Keys on PAM > Credentials > SSH keys > SSH keys through “New” in action button:
After that, a screen will be shown.
In section “Information”, we set the key owner in Username field (the same user in the server), the Device to connect remotely, a Key name, and the Key path where the keys were saved.
In the next section “Key data”, we set the Password (the passphrase), and the keys values, Private key and Public key respectively
And in the section “Device” we set the according to devices that will connect with the SSH keys:
Lastly, save the configurations.
Therefore, now we can connect to the server through menu PAM > Credentials > SSH keys > Remote access, and clicking on “Start session” button: