How To Setup SSH Keys – POFTUT

How To Setup SSH Keys

Ssh is a protocol designed to make network connections between hosts secure. Ssh is a defacto standard for Linux and related operating system. Ssh encrypts the connection between sides. Ssh gives terminal access between host and server. To get a terminal there need to be an authentication process. The authentication process is generally password based but there are some caveats for password-based authentication. Brute force attacks can guess the password and give access to the server. To make things more secure key based authentication can be used. It is far more secure and practical to use in logins or batch operations.

Creating Key Pairs

We will create key pairs. We may ask yourself why pair. Isn’t 1 key enough? In Asymmetric cryptography key pairs where each if different is used to complete each other. One key is named public which is known by the public. One key is named private and only known by the owner.

We have created a key pair based RSA algorithm. Our key pairs are 2048 bit. So is more secure as long as more longer key size. We can protect our key pair with passphrase but it is not practical for most situations. Our key pair is located by default users home directories .ssh file. Keep in mind that while working with ssh configuration we need root privileges. Best way to get root privileges uses the following command.

Adding Key to Remote Server

Now we have a key to use. We will add this key to a remote server for a user.

We use ssh-copy-id command to add our key for the root user in the remote server whose IP address is . After adding our key we can log in remote server without entering passphrase/password like this.

Disable Password-Based Authentication for SSH Configuration

After completing these steps we can disable password-based authentication for ssh server.

Open sshd_config file and change PasswordAuthentication and PermitRootLogin line like below

Apply SSH Server Configuration

Then restart SSH server to load with the new configuration.

Check SSH Server Status

Check if the SSH is working with the systemctl command like below.

Check SSH Service Status

Check SSH Service Status

How To Setup SSH Keys Infographic

How To Setup SSH Keys Infographic

How To Setup SSH Keys Infographic

1 Response

Leave a Reply

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

Enjoy this blog? Please spread the word :)