Create a Public/Private Key pair on Mac OS/X
Jump to navigation
Jump to search
The following steps create a public/private key pair (a digital identity) on Mac OS/X (or other systems which support the bash
shell):
- Supply your name and address. Type the following into the terminal window and press the "Enter" key, substituting your name and email in the requisite spot. If you make a mistake, type it again.
NAME_EMAIL="First Last <myself@example.com>"
- Show your digital identity (the public key half), creating an identity if it does not exist. Cut and paste the following block of commands into the terminal window. Press the "Enter" key after pasting.
if [ ! -d ~/.ssh ] ; then mkdir ~/.ssh chmod g=,o= ~/.ssh fi if [ ! -f ~/.ssh/id_ed25519 ] ; then ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -a 100 -N '' -C "${NAME_EMAIL}" fi printf 'Your public key is:\n' cat ~/.ssh/id_ed25519.pub
Your terminal window will afterward contain text similar to this:
myself@mybox:~$ NAME_EMAIL="First Last <myself@example.com>" myself@mybox:~$ if [ ! -d ~/.ssh ] ; then mkdir ~/.ssh chmod g=,o= ~/.ssh fi if [ ! -f ~/.ssh/id_ed25519 ] ; then ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -a 100 -N '' -C "${NAME_EMAIL}" fi printf 'Your public key is:\n' cat ~/.ssh/id_ed25519.pub Generating public/private ed25519 key pair. Your identification has been saved in /Users/myself/.ssh/id_ed25519 Your public key has been saved in /Users/myself/.ssh/id_ed25519.pub The key fingerprint is: SHA256:DpdZ3A21iSjsut9rWb69XgO37iOUoHTesa5/Ckl+bpc First Last <myself@example.com> The key's randomart image is: +--[ED25519 256]--+ | ... | | . . o + o | | o + o + | | . * o . | | . S +.o.+. | | = .o.o=o .| | . . Bo. oo| | . .o ==.E.| | ....oo=*X+.| +----[SHA256]-----+ Your public key is: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ26ZmUgPppkTHpMtJ/vyOLlhyy0bwB7wVaPj4UGkq4r First Last <myself@example.com> myself@mybox:~$
The next-to-last line printed, one long line beginning with "ssh-ed25519" and ending with your name and email, is your public key. You're going to copy and paste the whole line into an email in the step after next.