Using ssh-keygen to Generate Public Key and Private Key
\#linux #OS
ssh-keygen is a command to generate the public key and private key
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (<path>):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in <path>/.ssh/id_rsa.
Your public key has been saved in <path>/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xxx......
The key's randomart image is:
+---[RSA 3072]----+
| |
| |
| |
| |
| |
| |
+----[SHA256]-----+
Then you can see inside ~/.ssh folder, it will have two file id_rsa.pub and id_rsa
id_rsa.pub: public keyid_rsa: private key
Use cat command to show and copy the public key
cat ~/.ssh/id_rsa.pub
Last modified: 12 June 2025