To generate a private and public SSH key pair, run ssh-keygen.
- Running
ssh-keygenshows this prompt:
Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa ) : - By default, the keys save to the
.ssh/folder.
Things to note:
id_rsacontains the private key.id_rsa.pubcontains the public key.known_hostsstores the host keys of the servers you’ve connected to over SSH.
ssh-keygen -t rsa -C "your_email@example.com" generates an SSH key pair and associates it with your email.