Setting up SSH key pairs for more secure access

shape
shape
shape
shape
shape
shape
shape
shape

In today’s post we’re going to show you step by step how to create and use encrypted keys to increase the security of your SSH login.

First, let’s create the keys with the following steps:

  1. Open the terminal or command prompt.
  2. Enter the following command to generate an SSH key pair:
    ssh-keygen
  3. You will be asked to choose a location to save the keys. Enter a custom path or press Enter to accept the default location which is: /(user)/.ssh
  4. You will then be asked to enter a passphrase to protect your key. This is optional, but recommended for greater security.
  5. Two files will be generated: a private key (usually named id_rsa) and a public key (named id_rsa.pub).

Now we’ll show you how to copy and use the keys:

  1. Copy the public key to the remote server where you want to log in using the following command if it is copied from Windows: type $env:USERPROFILE\.ssh\id_rsa.pub | ssh username@remote_host "cat >> .ssh/authorized_keys"
  2. And the following command if copied from Linux: cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  3. You will be asked for the remote user’s password. Enter it and the key will be copied to the server.
  4. Now you can log in to the server without entering your password or just by typing in the passphrase.

See also our video tutorial available on our YouTube channel:

Master da Web, your Cloud solution!☁️

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest news

Latest news directly from our blog.