SSH keys are a method of logging into computer systems and servers without using passwords. SSH stands for Secure Shell, which is a network protocol that lets you connect to remote computers safely. Instead of typing a password each time you need access, SSH keys use a pair of related codes—one public and one private—to verify your identity automatically.
Free Guide to Understanding Payment Security →
The public key works like a lock that you can share with anyone. The private key is like the only key that opens that lock, and you must keep it completely secret. When you try to connect to a server, the system checks if your private key matches the public key on file. If they match, you get access without ever typing a password. This system is more secure than passwords for several reasons: SSH keys are much longer and more complex than passwords, they cannot be guessed through brute force attacks the same way passwords can, and they are not transmitted over networks where they might be intercepted.
SSH keys have become the standard for securing access to servers, cloud platforms, and development environments. Developers, system administrators, and anyone managing remote servers uses SSH keys regularly. Major platforms like GitHub, GitLab, Amazon Web Services, and Microsoft Azure all support SSH keys as a primary authentication method. Understanding how SSH keys work gives you insight into modern security practices used across the technology industry.
A practical takeaway from this section: SSH keys represent a shift from "something you know" (passwords) to "something you have" (a unique pair of codes). This distinction matters because it removes the human element of choosing weak passwords or forgetting them.
An SSH key pair consists of two related files: the public key and the private key. These files are generated together using mathematical algorithms that create a relationship between them. The most common algorithm is RSA, which creates keys through complex mathematical operations that make it practically impossible to derive the private key from the public key alone.
Learn How To Delete Emails From One Sender →
The public key is stored on any server or service you want to access. You can share this key freely with others, post it online, or distribute it however you need. Think of it like your email address—it is meant to be shared. The public key typically looks like a long string of characters starting with "ssh-rsa" or "ssh-ed25519" followed by a large block of encoded text and often ending with a comment like "user@computer".
The private key is stored only on your computer and must never be shared with anyone. This file is usually kept in a hidden folder called ".ssh" in your home directory. The private key also appears as a block of encoded text, but it starts with "BEGIN OPENSSH PRIVATE KEY" or similar text. If someone obtains your private key, they can access any system where your public key is stored. This is why protecting your private key is critical—you should treat it like you would treat the keys to your house.
When you connect to a server using SSH, your computer uses the private key to prove that you own the matching public key stored on that server. The server sends a challenge, your private key creates a response to that challenge, and the server verifies the response using the public key. This back-and-forth happens automatically in seconds. The actual password or private key data never travels across the network, which makes this system more secure than password-based authentication.
A practical takeaway: Think of SSH keys like a two-part lock-and-key system where the public key is the lock (safe to share) and the private key is the key itself (must stay hidden). This mental model helps explain why you can freely distribute your public key without compromising security.
Most people generate SSH keys using command-line tools available on Mac, Linux, and Windows computers. The standard tool is called "ssh-keygen," which comes built into most operating systems. The process involves opening a terminal or command prompt and running a single command: "ssh-keygen -t ed25519". This command tells your computer to create a new key pair using the ED25519 algorithm, which is newer and considered more secure than older RSA keys.
Get Your Free Guide to Walla Walla Housing Programs →
When you run this command, the system asks you where to save the key. For most situations, accepting the default location (usually "~/.ssh/id_ed25519") is fine. The system then asks you to create a passphrase—this is different from a password. A passphrase is an optional extra layer of security that protects your private key file itself. If you set a passphrase, anyone who gets access to your computer would still need that passphrase to use your private key. Many security guides recommend using a passphrase, especially if you use the same key on multiple systems or if your computer could be accessed by others.
After you complete the setup, two files are created: "id_ed25519" (your private key) and "id_ed25519.pub" (your public key). The ".pub" extension indicates it is safe to share. Some systems and services may ask for RSA keys instead of ED25519, in which case you would use "ssh-keygen -t rsa -b 4096" to create a 4096-bit RSA key.
Best practices for key generation include using ED25519 keys when possible since they are shorter and more secure, creating a strong passphrase if you decide to use one, storing your private key in the default location so SSH tools can find it automatically, and never sharing your private key with anyone. Additionally, you should consider creating different SSH keys for different purposes—for example, one key for GitHub, another for your work servers, and another for personal projects. This limits the damage if one key is compromised.
A practical takeaway: Generate your keys using "ssh-keygen -t ed25519" and accept the default location. If you want extra security on your personal computer, add a passphrase when prompted. This approach balances security with ease of use for most situations.
As your work grows, you may need multiple SSH keys for different purposes and different systems. A developer might have one key for GitHub, another for deployment servers, and another for cloud infrastructure like AWS or Azure. Managing these keys properly prevents confusion and reduces security risks. Each key pair you create should be stored in your ".ssh" directory with descriptive names that help you remember what each key is for.
Free Guide to Getting Your DD214 Discharge Document →
The SSH configuration file, located at "~/.ssh/config", lets you organize your keys and simplify your connection commands. This file tells SSH which key to use when connecting to which server. For example, you could set up your configuration so that when you connect to "github.com," SSH automatically uses your GitHub key, and when you connect to your work server, it uses your work key. You do not need to specify which key to use each time.
A sample SSH config file might look like this: You create different sections for different hosts. Under the host name "github.com," you specify that it should use the file "~/.ssh/github_key". Under another host entry for your work server, you specify a different key like "~/.ssh/work_key". You can also configure other options like port numbers and usernames. This setup means you only need to remember simple connection commands, and SSH handles the rest automatically.
When managing multiple keys, keeping an inventory helps you remember what each key is for. You might maintain a simple document that lists each key file name, which service it is used for, when it was created, and when you plan to rotate it. Regular key rotation means periodically creating new keys and removing old ones. This practice limits exposure if an old key somehow becomes compromised. Many organizations require rotating keys every 90 days or every year, depending on their security policies.
A practical takeaway: Use descriptive names for your key files like "github_key," "aws_key," and "work_server_key" instead of accepting the default names. Set up an SSH config file to organize which key connects to which service. This organization prevents mistakes and makes your SSH setup more manageable as it grows.
Your private key is your most valuable security asset in an SSH setup. Someone with access to your private key can connect to any server where your public key is stored, potentially accessing sensitive systems, data, or infrastructure. Protecting your private key requires attention to where it is stored, who can access it, and how you secure the device holding it.
Learn About Getting a Library Card →
On your local computer, private key files should have restricted permissions that only allow you to
This guide is for general information only and is not medical, financial, legal, or other professional advice. For decisions specific to your situation, consult a qualified professional. See our Editorial Policy.