To create an SSH public key on a Mac, you can use the built-in Terminal application and follow these steps:
Open Terminal on your Mac by going to Applications > Utilities > Terminal.
In the Terminal window, type the following command and press Enter:
ssh-keygen -t rsa
This will start the SSH key generation process.
You will be prompted to enter a file path to save the key. By default, it will save to the .ssh directory in your home directory. If you want to use the default, just press Enter. Otherwise, you can specify a different file path.
Next, you will be prompted to enter a passphrase. This is optional but recommended for added security. If you want to use a passphrase, enter it and press Enter. If you don't want to use a passphrase, just press Enter.
The key generation process will begin and you will see output similar to the following:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Once the process is complete, you will see a message similar to the following:
Your identification has been saved in /Users/yourname/.ssh/id_rsa.
Your public key has been saved in /Users/yourname/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:abcdefgh12345678abcdefgh12345678abcdefgh user@host
The key's randomart image is:
+---[RSA 2048]----+
| .+=+=+=+. |
| .=+=+=+=. |
| .. .+=+=+= |
| ..+=+=+= |
| .. .+=+= |
| ..+=+= |
| . .. |
| .. |
| oo|
+----[SHA256]-----+
Your public key is now stored in the file /Users/yourname/.ssh/id_rsa.pub. You can copy this file and use it to authenticate with SSH on remote servers.
Step 1: Get the public key Ask the end user to provide the public key by typing the following command:
cat ~/.ssh/id_rsa.pub
It will show a long random string starting with ssh-rsa:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ3GIJzTX7J6zsCrywcjAM/7Kq3O9ZIvDw2OFO