SSH keys are a pair of private and public keys. Private key - secret information stored by the user. The public key must be stored on a server that will be accessed via SSH.
Generating SSH Keys
On Linux systems, keys are generated as follows:
ssh-keygen [options]
The main options are -t to specify the encryption algorithm and -b to specify the key length:
ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519
When generating keys, specify the path to the file where the private key will be written. The public key will be written to a file named <path to file> .pub.
Copying the public key
The user's public key must be copied to the server, which will be accessed via the SSH protocol, to the ~ / .ssh / authorized_keys file:
ssh-copy-id -i ~ / .ssh / id_rsa.pub user @ host
user - the user account of the remote server.
host - the IP address of the remote server.
~ - the directory of the home folder of the remote server user.
When connecting, you need to enter the password of the remote server user.