- HOME
- More
- Best Practices
- What is key-based authentication? How it works and why it’s more secure
What is key-based authentication? How it works and why it’s more secure
- Published : August 28, 2026
- Last Updated : August 28, 2026
- 0 Views
- 7 Min Read
Passwords fail in predictable ways. They can be guessed, phished, reused across services, and leaked in data breaches—often without the account owner knowing for weeks or even months. Verizon’s 2025 Data Breach Investigations Report found that more than 20% of data breaches involve stolen or weak credentials.
This could be a serious security concern for services such as API access, server connections and email infrastructures where unauthorized access carries real consequences.
Key-based authentication solves this at the mechanism level. It provides a more secure alternative by using a cryptographic key or secret token instead of relying on a traditional password.
What is key-based authentication?
Key-based authentication is a method of verifying identity using a cryptographic key or secret token without using username-and-password credential. Users authenticate their identity using a public key and a private key pair that work together. The keys are mathematically linked codes, which are significantly harder to guess or crack through brute-force or credential-stuffing attacks.

How does key-based authentication work?
The key pair in authentication
Key-based authentication uses asymmetric cryptography between the public and private keys, and only the verified matching pair of keys will allow the access to the application or system.
- The private key is kept secret on the user's or application’s system. It’s used to create a digital signature during authentication and should never be shared.
- The public key can be distributed to the servers or services that need to authenticate the corresponding private-key holder. It’s used to verify signatures.
The authentication handshake process
- A user or application (client) generates a public-private key pair.
- The public key is uploaded to the server or service.
- The private key is stored securely on the user's device or system.
- When the user tries to log in, the server sends a cryptographic challenge.
- The private key signs the challenge.
- The server verifies the signature using the stored public key.
- If the signature matches, authentication is successful. If not, the request is denied with a 401 or 403 error.
SSH key-based authentication as an example
SSH (Secure Shell) key-based authentication is the most widely used form of this mechanism. The process works like this:
- Your SSH client connects to the server and identifies the public key it wants to use for authentication.
- The server checks if the public key is listed in the
authorized_keysfile for the requested user account. - If authorized, the server sends a random challenge to the client.
- The client uses the matching private key to create a digital signature over the challenge.
- The client sends the signature to the server.
- The server uses the public key to verify the signature. If valid, authentication is successful.
Key-based authentication vs. password authentication
| Factor | Password authentication | Public-key authentication |
|---|---|---|
| What's verified? | Knowledge of the password | Possession of a private key |
| What's sent over the network? | The password is provided during authentication | Only the public key, the private key is never sent |
| Brute-force risk | Depends on how strong the password is | Hackers cannot realistically guess a strong private key |
| Phishing risk | Attackers can trick you into entering your password on a fake login page | There's no password to enter or phish |
| Credential stuffing risk | Higher because people often reuse passwords across services | Very low because each key pair is unique |
| Revocation | Changing the password may not end existing sessions | Removing the public key prevents new logins using that key |
| Setup | Simple to use | Requires generating and adding a key pair |
| How to protect it | Use a password manager and MFA | Protect the private key with a passphrase, proper permissions, and secure storage |
When should you use key-based authentication vs. passwords?
Use key-based authentication when a system or application needs to authenticate automatically, or when you want to avoid relying on reusable passwords. Common examples include:
- SSH access to servers
- Automated deployment systems
- CI/CD pipelines
- Machine-to-machine authentication
- Software signing
- Certain certificate-based authentication systems
For human-facing applications, passwords can still be used when you combine them with strong security controls such as multi-factor authentication, password managers, and secure password storage.
What is API key authentication?
API key authentication is different from key-based authentication. In API key authentication, there’s usually no public/private key pair. Instead, the API provider issues a randomly generated secret token that the application sends with its requests. It’s generally a long, randomly generated value issued by an API provider to identify and authorize an application or integration.
The application sends the API key with its request, commonly through an HTTP header. The server validates the key and decides whether to authorize the request. Users must carefully protect the key because it’s a secret credential that travels with every request. A leaked API key can be used directly by anyone who gets access to it.
How does API key authentication differ from public-private key authentication?
| Factor | API key authentication | Public-private key authentication |
|---|---|---|
| Credential type | Shared secret token | Asymmetric key pair |
| Private key | None | Private key remains secret |
| Server stores | API key record | Public key |
| Authentication | Server validates the supplied token | Server verifies a digital signature |
| Use cases | REST APIs and service integrations | SSH, certificate-based authentication, signing |
| Credential exposure risk | A leaked token can be used directly | The private key is required to authenticate; the public key alone is useless |
| Revocation | Revoke, delete, or rotate the token | Remove or disable the authorized public key |
Common use cases of key-based authentication
Key-based authentication is widely used across cloud platforms, enterprise applications, and developer workflows.
Here are some common examples.
Secure server access
Developers use cryptographic key pairs to access a server. Instead of entering a password every time, they authenticate using their private key, which is faster and more secure.
API authentication
Many SaaS platforms allow applications to authenticate using API keys or cryptographic key pairs. This allows applications to communicate securely without asking users to enter a password for every request.
Cloud infrastructure
Cloud providers use key-based authentication to manage virtual computers and other infrastructure resources. It gives administrators a secure way to access systems without password-related risks.
Automated processes
Computer programs, automatic scripts, and digital setups need to log into servers and apps to do chores for us (almost 24/7). Key-based authentication lets them log in safely without storing a plaintext password in the codebase.
Enterprise environments
Many organizations use key-based authentication to protect internal systems, remote access, and administrator accounts where stronger security is required.
How key-based authentication works in ZeptoMail
When you send transactional email through ZeptoMail, authentication happens at two different places:
- API or SMTP authentication, which authenticates your application or mail-sending client to ZeptoMail.
- DKIM authentication, which allows recipient mail servers to verify a cryptographic signature associated with your sending domain.
API token authentication for sending requests
ZeptoMail’s email sending API uses a Send API key to authenticate API requests. The token is specific to the agent and is included in the authorization header when making an API request.
curl -X POST "https://api.zeptomail.com/v1.1/email" \
-H "Authorization: Zoho-enczapikey YOUR_SEND_MAIL_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"from": {
"address": "noreply@yourdomain.com"
},
"to": [
{
"email_address": {
"address": "user@example.com"
}
}
],
"subject": "Your order has shipped",
"htmlbody": "Your order is on its way."
}'ZeptoMail provides SMTP configuration details for its SMTP server, including the server name, supported ports, username, and authentication credentials.
| Method | Authentication type | When to use it |
|---|---|---|
| ZeptoMail API | Send API key in the authorization header | Applications that can make HTTP API requests |
| ZeptoMail SMTP | SMTP username and password | Applications or frameworks that require SMTP |
How to rotate API keys in ZeptoMail
Regular key rotation is a best practice for any API-based integration. In ZeptoMail, you can generate a new Send API key from the Agents section of your account. Once the new token is active, update your app’s settings with the new token and delete the old one. This keeps your mail sending working smoothly and stops old keys from being used.
DKIM authentication and deliverability
ZeptoMail uses DKIM to sign outgoing emails with a cryptographic signature. It creates this signature using a private key and lets receiving servers verify it with a public key in your DNS. Setting up the correct DKIM records in your DNS is crucial for email deliverability. Without a valid DKIM signature, emails are more likely to be marked as spam by Gmail, Outlook, and others.
Best practices for using key-based authentication
Following a few simple best practices can help you keep your systems secure and get the most out of key-based authentication.
Generate strong keys
Use only trusted encryption methods and recommended key sizes when creating keys. Avoid older algorithms that are no longer considered secure.
Keep private keys safe
Never store private keys in plain text or include them in your source code. Instead, store them in a secure location, such as an encrypted vault or hardware security device.
Rotate keys regularly
Replace your keys from time to time instead of using the same ones forever. It reduces the risk of the key being exposed or stolen.
Remove unused keys
Delete keys that are no longer needed, such as those belonging to former employees, old applications, or discarded systems. Regularly reviewing your keys helps prevent unauthorized access.
Use multi-factor authentication (MFA)
For systems that handle sensitive data, combine key-based authentication with multi-factor authentication (MFA). This adds an extra layer of security by adding another form of verification.
Monitor login activity
Keep an eye on authentication logs and review login activity regularly. This helps you spot any unusual login attempts, repeated failures, or other suspicious behavior before they become bigger security issues.
Conclusion
Key-based authentication works with cryptographic keys, ensuring a safer and more reliable way to verify identities than traditional passwords.
As more businesses move to cloud services, APIs, and automated workflows, adopting key-based authentication can help protect critical systems while simplifying secure access. For transactional emails, ZeptoMail’s token-based API authentication, paired with correct DNS setup, delivers a secure and highly deliverable solution.
FAQ
1. What is key-based authentication?
Key-based authentication is a method of verifying identity using cryptographic keys instead of passwords. The most common forms are asymmetric key pairs (using public and private keys) and shared-secret API keys (where a token is included in each request).
2. Why is key-based authentication more secure than password authentication?
Password authentication relies on a shared secret (between the user and the server) that can be stolen from either side. Key-based authentication keeps the private key on your device and proves you own it without sharing it with the server. This reduces risks such as phishing, credential stuffing, and password guessing.
3. How does key-based authentication work?
In SSH authentication, you create a public/private key pair. The private key stays on your device, while the public key is added to the server. During login, the server verifies that you have the private key without receiving it.
For API keys, a secret token is sent with the request, and the server validates it.
4. What is the difference between a public key and a private key?
The private key is kept secret and stays on your device. The public key can be safely shared with servers to verify your identity. The public key alone cannot be used to authenticate without the corresponding private key.
5. What are the different types of key-based authentication?
Common types of key-based authentication are:
- Public-key authentication: Uses a public/private key pair for SSH and other cryptographic systems.
- API key authentication: Uses a secret token to authenticate API requests.
- DKIM: Signs emails with a private key and uses a public key published in DNS to verify them.


