To create a new SSH key pair, run the "ssh-keygen" utility on your local machine. The "ssh-keygen" utility is available on all major operating systems. In macOS or Linux, run "ssh-keygen" in the Terminal app. On Windows, run "ssh-keygen" in the Command Prompt app.
You will be asked to provide the file name and password for a new key pair. Press Enter to accept the default file name.
~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/user/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/user/.ssh/id_rsa. Your public key has been saved in /Users/user/.ssh/id_rsa.pub.
To view the public key, run (assuming the default file name):
~$ cat ~/.ssh/id_rsa.pub
A text, similar to the one below, will appear on your screen. This is your public key: