Secure Shell (SSH) is a widely used protocol for secure communication over an insecure network. This application layer protocol is extremely popular and allows users to remotely manage the operating system. SSH key pairs provide a secure and convenient way to authenticate and log into remote servers without using passwords. Two important commands for managing SSH keys in Linux are ssh-keygen and ssh-copy-id. This article aims to introduce you to these commands, show an example of how they work and how it can help you use the server correctly and safely.


Installing the ssh-copy-id command

What is ssh-copy-id? First of all, this utility is part of the OpenSSH package and is available in all major Linux distribution repositories. In this article, for example, a server on Dedian 12 version is used. With this utility, you will be able to use your package manager to install this command. This utility also helps you copy the SSH public key to a remote server and add it to a file. To install the ssh-copy-id tool on Debian, use the following command:

sudo apt-get update && sudo apt-get install openssh-client

You can check the command like this – ssh-copy-id. The output will be like this

To start actively using it, you can run the following command:

ssh-copy-id user_1@_your_IP_address[or name]

  • user_1 – this is your username on the remote server.
  • your_IP_address – this is the address or name of the remote server.

How to generate an SSH key in your Debian VPS

What is ssh-keygen? This is a special utility in the Unix/Linux environment designed to generate, manage and convert SSH (Secure Shell) keys. SSH keys are used for secure authentication when connecting to remote servers. This works automatically, you can simply enter the command and you will receive the following response

ssh-keygen provides many options for configuring keys, including choosing an algorithm, changing the bit length, specifying a file name, and other options. It is an essential tool for working with SSH keys in a secure environment.