In order to generate SSH keys in Ubuntu, we need the ssh-keygen utility. This utility comes with the openssh-client deb package, which should already be installed by default. And so, let's get started.
1. First you need to create a folder for storing ssh keys if it is not already there
mkdir ~/.ssh
2. Run the command to generate ssh keys
ssh-keygen -t rsa -b 2048 -C igor-sverdlov@mail.ru– The
ssh-keygen -t rsa -b 2048 -C igor-sverdlov@mail.ru Enter file in which to save the key (/home/madskill/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/madskill/.ssh/id_rsa. Your public key has been saved in /home/madskill/.ssh/id_rsa.pub. The key fingerprint is: SHA256:FrcsHSW/ATlQzIhOGdU8oT/CqNJGeWZWgWYY0XA0yag igor-sverdlov@mail.ru The key's randomart image is: +---[RSA 2048]----+ | +X=B+O=o. | | o.@..oO= | | . = + ooo | | E ..+ * o o | | o * S * . | | o * . o . | | . + | | o | | | +----[SHA256]-----+As a result, we will get two files
ls ~/.ssh id_rsa id_rsa.pub
It remains to set the correct file permissions and you're done.
chmod 700 ~/.ssh chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub