Home / Guides / SSH vs RSA vs PGP
SSH vs RSA vs PGP Keys: What's Actually Different
These three terms get used almost interchangeably, but they're not the same kind of thing. Here's how they actually relate.
The short version
RSA is the math. It's an asymmetric encryption algorithm: a way of generating a public/private key pair where anything encrypted with the public key can only be decrypted with the private one (and vice versa for signing). SSH and PGP are two different things built on top of that math (or on top of similar asymmetric algorithms), each with their own file format, their own trust model, and their own purpose. The same underlying RSA key pair can, in principle, be reformatted to work in either context. They're not fundamentally different cryptography, just different applications of it.
SSH keys: authenticating to a server
An SSH key pair proves your identity to a remote server without typing a password. You keep the private key on your machine; the server holds a copy of your public key and uses it to verify that whoever's connecting actually holds the matching private key. SSH public keys are typically stored "naked," a single line like ssh-rsa AAAAB3NzaC1yc2EA... or, increasingly, ssh-ed25519 AAAAC3NzaC1lZDI1NTE5... for the newer, faster Ed25519 algorithm. There's no built-in trust infrastructure beyond "does this key match what the server has on file." You (or a service like GitHub) manage that association directly.
PGP/GPG keys: encrypting and signing messages or files
PGP (Pretty Good Privacy) and its open-source implementation GPG (GNU Privacy Guard) solve a different problem: encrypting a message or file so only a specific recipient can read it, or signing something so a recipient can verify it genuinely came from you and wasn't altered. PGP keys are also commonly RSA under the hood (though other algorithms are supported), but the file format is different: ASCII-armored blocks like -----BEGIN PGP PUBLIC KEY BLOCK-----. PGP also layers on its own decentralized trust model (the "web of trust"), where people cross-sign each other's keys instead of relying on one central authority.
Side by side
| Aspect | SSH | PGP/GPG |
|---|---|---|
| Actual purpose | Authenticate to a remote server | Encrypt/sign messages and files |
| Typical algorithm | RSA or Ed25519 | RSA (commonly), among others |
| Public key format | Single line, "naked" (ssh-rsa AAAA...) | ASCII-armored block |
| Trust model | Direct: you or the server operator manage the key list | Decentralized "web of trust" via cross-signing |
A note on this site's tools
This site doesn't yet include a dedicated SSH or PGP key generator. Native RSA key generation itself is straightforward via the browser's Web Crypto API, but producing a correctly-formatted SSH public key or a properly PGP-armored, correctly-structured key block is meaningfully more involved than reformatting random bytes. Getting either wrong risks shipping a key that looks right but doesn't actually work with real SSH or PGP tooling. That's being built carefully rather than rushed. Check the generator for updates.
Frequently asked questions
Can I use the same RSA key for both SSH and PGP?
Mathematically, yes. The same RSA key pair can in principle work for both, since RSA is the shared algorithm underneath. In practice, security guidance generally recommends against reusing one key across different purposes, since it means a single compromise affects everything that key was used for. Most tools also expect the key in their own specific file format, so you'd need to convert it either way.
Is RSA still secure, or should I use something newer?
RSA with a sufficient key size (2048-bit minimum, 4096-bit for extra margin) remains widely used and accepted. For SSH specifically, Ed25519 has become the increasingly preferred modern default: it produces smaller keys, verifies faster, and is considered at least as secure as RSA at commonly used key sizes.
- OpenSSH documentation and RFC 4253, The Secure Shell (SSH) Transport Layer Protocol
- IETF RFC 4880, OpenPGP Message Format