Generating An SSH Key Using ssh-keygen¶
In order to facilitate logging in without having to type your ONID password every time, you can generate a ssh key that validates your identity without a password. Using this method also eliminates the need for using DUO authentication.
Here is a step-by-step guide on how to generate an ED25519 SSH key using the ssh-keygen command in Linux, MacOS,
Windows Subsystem for Linux (WSL), and Windows Terminal (powershell & cmd).
-
Open Terminal: Launch your terminal application. This can typically be found in your system's applications menu.
-
Generate ED25519 SSH Key: Enter the following command to begin the key generation process:
This command tells
ssh-keygento generate a new key using the ED25519 algorithm. -
Specify File Location: After running the command, you'll be prompted to specify the file in which to save the key. If you do not have a pre-existing key*, press
Enterto accept the default location (~/.ssh/id_ed25519).
Possible Key-pair Clobber
Please be advised that if you already have an SSH key-pair at ~/.ssh/ed_ed25519(.pub), pressing Enter here will
overwrite that existing key, potentially leaving you unable to connect to systems that (previously) used that
key-pair.
-
Enter Passphrase (Recommended): Next, you'll be asked to enter a passphrase. This adds an extra, recommended layer of security to your key. If you don't want to use a passphrase, simply press
Enter. -
Confirm Passphrase: If you entered a passphrase, you'll be asked to confirm it. Enter the same passphrase again and press
Enter.
Your SSH key has now been generated and saved in the specified file.
-
Copy Public Key to Infrastructure: Run this command to copy the public key to the infrastructure:
(replaceid_ed25519.pubwith your file name if you altered the path/file name in Step 3)When prompted, enter your ONID password, and enter
1to send a push to your Duo mobile app. Confirm the log-in using your phone.
Alternative to ssh-copy-id
If you can't seem to get the ssh-copy-id command to work, you can simply log in as usual to the shell
machine and copy-paste your public key on a new line in the ~/.ssh/authorized_keys file.
-
Test for Success: Run this command to test your ssh keys:
Potential Issues¶
-
Permission Denied: If you see a "Permission denied" error when trying to generate your key, it may be due to incorrect permissions on your
.sshdirectory or your home directory. You can fix this by runningchmod 700 ~/.sshto set the correct permissions. You may also need to do the same in your home directory on the infrastructure, along withchmod 600 ~/.ssh/authorized_keys. -
Overwriting Existing Key: If you already have an SSH key at the default path,
ssh-keygenwill ask if you want to overwrite it. Be careful not to overwrite a key that you're currently using, as you could lose access to systems that are configured with the old key. -
Lost Passphrase: If you forget your passphrase, you'll need to generate a new key. There's no way to recover a lost passphrase.
Reminder
Remember, keep your private key secure and never share it with anyone. Your public key, on the other hand, can be shared freely and is used by others to encrypt messages that only you can decrypt with your private key.