This post describes how to create an SSH key pair (public/private keys) on macOS and how to use it to connect to a server.
Use terminal to create key pair in your home directory:
ssh-keygen -t rsa
When asked for the file name, type any suitable name, for example ssh/admin.
This will create ssh folder and admin.pub (public key) and admin (private key) files in it.
Connect to a server using SSH keys
Assuming you somehow imported your public key into a server, you can now connect from macOS terminal to the server:
ssh -i <path to private key> <login>@<serverIP>
ssh -i ssh/admin firstname.lastname@example.org
Here the login must match the login defined in the end of public key file. When importing this file, you can change it as you want. For example, public file generated for admin in the example above will have the admin in the end of the file. You can change it to adminuser when uploading to the server to be able to log in under adminuser name.