To create SSH key pair we can use ssh-keygen:
-t Specifies the type of key to create. The possible values are “dsa”, “ecdsa”, “ed25519”, or “rsa”.
-b bits Specifies the number of bits in the key to create. For RSA keys, the minimum size is 1024 bits and the default is 3072 bits. Generally, 3072 bits is considered sufficient
-C comment Provides a new comment. This can be any string you want to help identify the key. As this keypair is unique and represents an identity of the (e.g. repository) user, I tend to use email format: user@domain
In case of Ed25519 there is no need to set the key size, as all Ed25519 keys are 256 bits. Older SSH clients and servers may not support these keys.
$ ssh-keygen -t ed25519 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bojan/.ssh/id_rsa): ./key-pair--ec2--my-app
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./key-pair--ec2--my-app
Your public key has been saved in ./key-pair--ec2--my-app.pub
The key fingerprint is:
SHA256:Hft9KWA0w7qalQIRUFBX3MunZ8HJqm0LPXb2P/zcKKI
The key's randomart image is:
+---[RSA 4096]----+
| o=+ .o.. |
| o ... |
| . o=+ . |
| . .o=o* |
| . S.oo+ . |
| . =+.+ .|
| . =o+++o..|
| =.+o= o*.|
| oE..o....O|
+----[SHA256]-----+
-rw------- 1 bojan bojan 3434 May 27 17:27 key-pair--ec2--my-app
-rw-r--r-- 1 bojan bojan 749 May 27 17:27 key-pair--ec2--my-app.pub
$ xclip -sel clip < ~/.ssh/id_rsa.pub
No comments:
Post a Comment