Generating SSH Public and Private Keys
SSH keys are an easy way to authenticate access across machines and for automated processes. An SSH key is composed of two parts: a private key, and a public key. In order to access an external machine you'll need to send over a public key (pubkey). Here's how to do that.
On Mac and Linux:
Check first to see if keys are already available. Open the terminal and run cat ~/.ssh/id_rsa.pub
. The key should look something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDPmN5W+fIRqsPUkRNy2Y/+XycbQSeBsGi8jmFcz6SxVbXQjHI8kYxV2hOjhav+PUTYGOo9Zt67QxAkAJoHCIgc69r3KwZISJ7n32JOVgDY3ryZY3fBB52y8kbidX1fiIlBGRpanId4e2jfskVjrmU89cRgeOCJtmq45GKbzCQFlcPOd+9Qxwnl676VksqWgPnv6UYw5ZEyDBKGJDThFORA7pP5c0nTCQjhDNXztALKKqvahbmKaYoeWS80+zrIQ/MTAtwtQ/RCLJxL9hjmHSJb4+n1J4e4qamUIslIwCT6qA61aye/PVWgYVL1xdRF0rwylM6ucGJqauMt2kPl1jK0/tbzeta+lXdaS1QMsdqRGhCFSCmFXOQIxr8Bq0/7D1NOPKIcOai6TRG7H6SA38mrx/EQIncTrX9Pc0tnH5EmsMZn2x1FhFPjI+HaBdDb7Pv+xAnITCGt7FpXlwOLeDSMxlhsVY+8zdSX79lPTlCVqY4hehN27jKxP9QoKUsSE= username@computer
If the key comes up, simply run pbcopy < ~/.ssh/id_rsa.pub
to copy the public key to your clipboard.
If the command comes up blank, you may need to generate ssh keys. Run ssh-keygen -t rsa
(leave the file and the passphrase questions blank). Then run the pbcopy command above to copy the key to your clipboard.
On Windows:
To generate SSH keys on Windows you'll need to have OpenSSH Client installed. Go to the "Optional features" link in Settings>Apps>Apps & features and see if OpenSSH Client is listed; if not, click the plus sign next to Add a feature, select OpenSSH Client from the list, and install.
Open Command Prompt and type ssh-keygen
. If a key already exists you'll be asked whether you want to overwrite the file (in most cases you don't and you can skip ahead to the key copy section). Hit enter to leave the passphrase blank.
The default folder the keys will be created in is \Users\<yourusername>\.ssh\
. Navigate to that folder using the cd
command and run clip < id_rsa.pub
to copy the public key to your clipboard