Custom key for SSH

$ ssh-keygen
Enter file in which to save the key (/home/petr/.ssh/id_rsa): /home/petr/my.key
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/petr/my.key.
Your public key has been saved in /home/petr/my.key.pub.
The key fingerprint is:
SHA256:t7oRcfThgNf5w8kXl+pg6Xgso/BJtBDt4T42vFUpZ7U petr@pc
The key's randomart image is:
+---[RSA 2048]----+
|      .  .o...  .|
|     . o...+oo o.|
|      + o.. *+o.o|
|     . + + O E* .|
|      = S @ o  o |
|     . O B = .   |
|      = O =      |
|       = o       |
|        o.       |
+----[SHA256]-----+

To use this key you have 2 choices: run command

ssh -i ~/my.key posvic.eu

or edit SSH config file and specify IndetityFile for host. Then is no need to use parameter -i.

# ~/.ssh/config
Host posvic.eu
    IdentityFile ~/my.key
ssh posvic.eu

Leave a Reply

Your email address will not be published.