22.04.2023

Adding a public SSH key to a server§ 

When connecting to a server using SSH, using ssh user@server for example, you will be prompted to enter the password for the user on the server. However, you can avoid this step by adding your public SSH key to the server.

ssh-copy-id -i <path to your ssh key> user@server

Once done, using ssh user@server will require the SSH key password, but not the user password. This may not seem at first like a gain, but if you use the ssh-agent, the agent will remember the key during the session, which means you will have to input the SSH key password only once.

This also has some security benefits. If you disable ssh password login on the server, using only the access via your key, this will make it harder to access your account with bruteforce.