Server Gigabit Guide

How to Use SSH Keys with Your Server Gigabit’s Server?

You are here:
Estimated reading time: 3 min

In today’s world of cybersecurity, simply using passwords to protect your Server Gigabit’s server is no longer enough. Hackers can easily crack passwords using brute force attacks or other methods, putting your server at risk. A more secure method of authentication is to use SSH keys.

What are SSH Keys?

SSH keys are a cryptographic key pair that consists of a public key and a private key. The public key is shared with the server, while the private key is kept secret on your local computer. When you log in to your server using SSH keys, the server encrypts a challenge message using your public key. You then decrypt the challenge message using your private key, and the server verifies that the decrypted message matches the original challenge message. This process ensures that only you can access your server.

Benefits of Using SSH Keys

There are several benefits to using SSH keys to authenticate with your Server Gigabit’s server:

  • Increased security: SSH keys are much more secure than passwords because they cannot be brute-forced or guessed.
  • Convenience: Once you have set up SSH keys, you will not need to enter your password every time you log in to your server.
  • Flexibility: SSH keys can be used to authenticate with any server that supports SSH key-based authentication.

How to Generate SSH Keys

Linux

  1. Open a terminal window on your local computer.
  2. Enter the following command:
ssh-keygen -t rsa

This command will generate a pair of SSH keys: a public key and a private key. The private key will be saved to the file id_rsa, and the public key will be saved to the file id_rsa.pub.

Windows

  1. Install PuTTY.
  2. Open the Windows search bar and search for “PuTTYgen”.
  3. Open it.
    Use the PuTTY Key Generator to generate SSH keys for Windows.
  4. Just click on “Generate” and move your mouse over the blank field.
    PuTTY key generator for Windows can create SSH keys using the RSA, DSA, ECDSA, ED25519, and SSH-1 (RSA) algorithms.

How to Upload Your Public Key to Your Server Gigabit

You can upload your public key to your Server Gigabit using a variety of methods, such as FTP or the server console.

Uploading Your Public Key via FTP

  1. Start your FTP program and connect to your server as root.
  2. Create a directory in the root directory called .ssh.
  3. Create a file called authorized_keys in the .ssh directory.
  4. Paste your entire public key into the authorized_keys file.
  5. Save the authorized_keys file.

Uploading Your Public Key via Console

  1. Log in to your server as root via SSH.
  2. Create the .ssh directory and switch to it using the following command:
mkdir /root/.ssh && cd /root/.ssh
  1. Create and open the authorized_keys file using the following command:
nano authorized_keys
  1. Paste your entire public key into the file and save it by pressing [CTRL+O].
  2. Exit the editor by pressing [CTRL+X].

How to Use Your SSH Private Key

To use your SSH private key to log in to your Server Gigabit’s server, you will need to use an SSH client such as PuTTY.

Using Your SSH Private Key with PuTTY

  1. Open PuTTY.
  2. Under “Category” on the left-hand side, select “Connection”.
  3. Select “SSH” from the list of protocols.
  4. Click on “Auth” to open the authentication settings.
  5. Click on “Browse” and select your private key file.
    Follow these four steps to select your private key via the PuTTY key generator.
  6. Enter the IP address of your server in the “Host Name” field.
  7. Choose a profile name in the “Saved Sessions” field.
  8. Click on “Save” to save your profile.
    PuTTY settings 2

Now you can double-click on your saved profile to log in to your server. You will be prompted to enter your username, but you will not be prompted to enter your password.

Testing SSH Key Authentication

Once you have set up SSH keys, you can test to make sure that they are working by trying to log in to your server using your SSH client. If you are able to log in without being prompted to enter your password, then SSH key authentication is working properly.

Disabling Password Authentication

It is a good security practice to disable password authentication once you have set up SSH keys. This will prevent anyone from logging in to your server using a password, even if they know your password.

To disable password authentication, you will need to edit the /etc/ssh/sshd_config file on your server. Find the following lines and change them to “no”:

ChallengeResponseAuthentication no
PasswordAuthentication no

Once you have made these changes, save the file and restart the SSH service using the following command:

systemctl restart ssh

Now, when you try to log in to your server using a password, you will be denied access. You will only be able to log in using SSH keys.

Removing SSH Key Authentication

If you ever decide to remove SSH key authentication and re-enable password authentication, you will need to edit the /etc/ssh/sshd_config file and change the following lines back to “yes”:

ChallengeResponseAuthentication yes
PasswordAuthentication yes

You will also need to delete the .ssh directory on your server using the following command:

rm -rf /root/.ssh

Once you have made these changes, restart the SSH service using the following command:

systemctl restart ssh

Now, you will be able to log in to your server using either SSH keys or a password.

Conclusion

Using SSH keys to authenticate with your Server Gigabit is a much more secure way to protect your server than using passwords. SSH keys are much more difficult to crack, and they provide a more convenient and flexible way to log in to your server. If you are not already using SSH keys, I highly recommend that you set them up.

 

Was this article helpful?
Dislike 0
Views: 17