SSH keys are useful to secure your root account or make your ssh connection easier and faster without many passwords for each machine. This guide will show you how to generate the ssh key.
$ cd ~/.ssh $ ls
Check if the directory contains files named for ex.
id_dsa.pub. If you have this files you are ready to go and you can check further steps here "How to enable SSH key login". Otherwise go to step 2.
To generate new SSH key run the code below. You can use default path or pass your own.
$ ssh-keygen -t rsa -C "email@example.com" Generating public/private rsa key pair. Enter file in which to save the key (/your_home/.ssh/id_rsa):
Now you need to enter a passphrase. You can leave it blank but we strongly recommend to use passphrase. Only downside of this is then having to type it each time you use the key. But passphrase makes key secure even if it fall into an unauthorized user possession.
Enter passphrase (empty for no passphrase): Enter same passphrase again:
Finaly you should see something like this:
Your identification has been saved in /home_path/.ssh/id_test. Your public key has been saved in /home_path/.ssh/id_test.pub. The key fingerprint is: 30:b2:bd:88:38:90:85:8d:88:23:fc:97:af:17:83:e8 sample@somehost The key's randomart image is: +--[ RSA 2048]----+ | | |++ | |B.o . o | |.+. +.o | |o .ooo S | |.. o.o.+ | |o o . ..o | | . E .. | | .. | +-----------------+
You will always use only
id_rsa.pub file. Do not give the
id_rsa file to anyone, it contains your private key.