Creating SSH keys
The Files That Make Up an SSH Key
When you create an SSH key, your computer saves two files in a hidden folder called ~/.ssh/.
Both files start with id_ followed by the method name — for example, id_ed25519.pub and id_ed25519.
- Public key (
id_ed25519.pub): You can share this freely, including by adding it to services like GitHub. - Private key (
id_ed25519): Never share this. Don’t email it, copy it to another computer, or post it anywhere.
Tip: On Linux and macOS, folder names that start with a period (like .ssh) are hidden automatically, so they won’t clutter your normal folder view.
To view your public key so you can share it, type this in your terminal, then copy the text it shows you:
cat ~/.ssh/id_ed25519.pub
Checking for Existing SSH Keys
Before making a new key, check whether you already have one. Type:
ls -al ~/.ssh
If you see files that start with id_, you already have a key. The one ending in .pub is public; the one with no ending is private.
If the ~/.ssh folder doesn’t exist, is empty, or has no id_ files (e.g., id_ed25519), you’ll need to make a new key using the steps below.
Note: You can use one key for several servers, but many people prefer separate keys for different systems.
Working with Linux and Apple macOS
Creating an SSH key works the same way on Linux and macOS. The only difference is where your home folder lives:
- macOS:
/Users/yourusername - Linux:
/home/yourusername
You don’t need to remember this, though — just type ~/.ssh, and your computer will find the right folder either way.
Note: macOS can also store your key’s passphrase in Apple Keychain, so you don’t have to type it every time. This is the only real difference between the two systems.
Working with Windows
Creating an SSH key on Windows works almost the same way as on Linux and macOS. Modern versions of Windows already include the tools you need.
Open PowerShell or Command Prompt and type:
ssh-keygen -t ed25519 -C "user@example.com"
Windows saves your keys at C:\Users\yourusername\.ssh\
Note: Programs like PuTTY, Git Bash, or WSL can also create SSH keys, but using PowerShell or Command Prompt is the simplest way.
Adding a Passphrase to Your SSH Key
While your key is being created, you’ll be asked to enter a passphrase.
A passphrase locks your private key. Even if someone gets into your computer, they can’t use your key without also knowing the passphrase.
Best choice: Use a string of 4 or 5 random words, like purple garden lamp river. A phrase like this is easier to remember than a short, complicated password — and it’s harder to crack, too.
Skipping the passphrase: If you press Enter twice, your key won’t have a passphrase. This lets you log in without typing anything, but it also means anyone who gets your private key can use it right away. We recommend always setting a passphrase.
Step-by-Step: Creating an SSH Key
- Open your terminal. Use Terminal on Linux or macOS, or PowerShell/Command Prompt on Windows.
- Type this command, replacing
netIDwith your own Lafayette NetID (your Lafayette username):ssh-keygen -t ed25519 -C "netID@lafayette.edu" - Choose where to save it. Press Enter to accept the default location shown on your screen:
Generating public/private ed25519 key pair. Enter file in which to save the key (/home/username/.ssh/id_ed25519): [Press Enter]If a key already exists there, you’ll see a message asking to overwrite it:
/home/user/.ssh/id_ed25519 already exists. Overwrite (y/n)?Type
nand press Enter to keep your existing key safe. Check whether you’re still using that key before replacing it. - Set a passphrase. Type a passphrase, press Enter, then type it again to confirm:
Enter passphrase (empty for no passphrase): Enter same passphrase again: - Confirm it worked. You’ll see a message showing where your key was saved and a “fingerprint” — a short code that identifies your key:
Your identification has been saved in /home/username/.ssh/id_ed25519 Your public key has been saved in /home/username/.ssh/id_ed25519.pub The key fingerprint is: SHA256:UqU2WDrh5ueCBPw9dfokFYn2ZnSsqtOgqBIRf04QnpU netID@lafayette.edu - Share your public key. Copy the contents of
id_ed25519.puband send it to your system administrator.