Alxblsk.com Logo
RE•DONE
Blog by Aliaksei Belski

How to generate an SSH key on MacOS?

Published: September 1st, 2020gitssh-key

How to generate an SSH key on MacOS?

SSH (Secure Shell) - is a network protocol that helps to perform secure operations. In terms of Git, this protocol helps to establish a secure connection without entering a login-password pair on every operation. Instead, it suggests a public key stored on a computer, that is used for establishing a connection with a remote server, which also knows the key. This is a convenient way to work with repositories on a long-term basis,

To generate an SSH key on MacOS, open the Terminal and type

ssh-keygen -t rsa

which starts the process of key generation. You can enter an optional passphrase to add a security factor.

Once the passphrase is selected, a private key is saved with the default name id_rsa . This private part should be kept there and never shared.

Once you're ready to import a key to third-party systems (like GitHub), you need to copy the public key. To place the key to the clipboard, open the Terminal and type

pbcopy < ~/.ssh/id_rsa.pub

Then you're ready to paste the public key. Once the key is set, you can download any repository connected with your account.