Blog

Generate and show SSH Key

To generate and output an SSH key on Linux or macOS, such as for authentication with GitHub, SSH sessions, etc., you can use the following two commands:

To generate the key:

ssh-keygen -t rsa -b 4096 -C "mail@example.com"

To output the key:

cat ~/.ssh/id_rsa.pub

These commands will generate an RSA key with a length of 4096 bits and an email address comment, and then output the public key (located at ~/.ssh/id_rsa.pub).