How to configure SSH keys with Linux Command Line
- KnowledgeBase /
- VPS serveur dédié /
- How to configure SSH keys with Linux Command Line
How to configure SSH keys with Linux Command Line
In this tutorial, we will install encrypted keys for authentication by SSH. There are many benefits to this type of installation that include:
No need to enter a password (unless you encrypt your keys with password protection * recommended *)
Once public / private key pair authentication is configured, you can disable password authentication completely and allow access via the key. Stops brute force attacks in his titles.
We must first create a public / private key pair on the client that we will use to connect to the server.
You execute the command below. Be sure to change the "solarvps_key" comment to reflect your key comment that you want to have to help remember what the key is for.
-B uses 2048-bit encryption and -t is of the RSA type. Make sure to give your key a password for more security!
Output should look like:
# ssh-keygen -b 2048 -t rsa -C "zenhosting_key" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 45:15:66:f2:03:a6:e9:0e:49:a4:12:b7:61:f9:f4:8e solarvps_keyThe command will create two files in your (hidden) ~ /. Ssh called id_rsa and id_rsa.pub. id_rsa is your private key and id_rsa.pub is your public key.
Now let's fix the permissions on the key files:
The above permissions are needed if StrictModes is set to yes in / etc / ssh / sshd_config (default).
Now, copy the contents of the id_rsa.pub file so that we can put the public key on the server we are trying to access via SSH keys only. To do this, you can follow
# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt+PzzOFcecabwsXnjPPd+eqrqF5d2qh6kRIbnInSgwqWlPvnyfxa2Ye1xhGjCssbYdPWA7epJ/42yMFQfg6RGynW9XjWMomWeA/1+2LGY4B7JBJQfuTdDB/AimJRQvlSmxklfktmuqx0S8u67mLdkRWY+uQD8Ec7TCxWC9pU5Hv3Hq4Rfg5KLZl/gcJyMCr3nhKXXnL65pAM0EdCmkefHxvHJ4InVuzXmDru7GVQXH1bd3Uy9UIRhIs9wORlTvwesUzWEH/eTCjGSTgGRaEguo9FISRcilODuYQrcrvN8eILZxXNsiprw0azMibonkb3yuQ6mfVxtRoB4JL3vsFIbw== solarvps_key
Commander
Open ticket
Submit a support ticket