DEV Community

KALPESH
KALPESH

Posted on

Authentication Methods Overview

1️⃣ Password Authentication

Users authenticate using a username and password.

  • ✅ Simple to implement

  • ❌ Less secure if:

    • Weak passwords are used
    • Passwords are reused
    • Credentials are intercepted

⚠️ Should always be combined with HTTPS/SSH encryption.

Best practice: Enable MFA along with passwords.


2️⃣ Public Key Authentication (SSH Key-Based)

Uses asymmetric cryptography with a key pair:

  • 🔓 Public Key → Stored on server

  • 🔐 Private Key → Stored securely on client

More secure than password authentication.


🔑 SSH Key Generation (Client Side)

ssh-keygen
Enter fullscreen mode Exit fullscreen mode

This generates:

  • id_rsa → Private Key (Keep Secret ❗)

  • id_rsa.pub → Public Key (Shareable)


🖥️ Server Configuration

  1. Go to:

    ~/.ssh/
    
  2. Paste the client’s public key into:

    authorized_keys
    

🔌 Connect to Server

ssh <username>@<server-ip>
Enter fullscreen mode Exit fullscreen mode
  • Use private IP if inside same VPC

  • Use public IP if accessing from internet

Test the Connection

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

🔐 Using PEM File (Example: AWS EC2)

When launching an EC2 instance:

  • You download a .pem file (private key).

  • AWS stores the corresponding public key on the server.

Connect using:

ssh -i <path-to-pem-file> <username>@<public-ip>
Enter fullscreen mode Exit fullscreen mode

Example:

ssh -i mykey.pem ec2-user@54.x.x.x
Enter fullscreen mode Exit fullscreen mode

📦 SCP (Secure Copy Protocol)

Transfer files securely over SSH:

scp -i <path-to-pem-file> <local-file> <username>@<server-ip>:<remote-directory>
Enter fullscreen mode Exit fullscreen mode

Example:

scp -i mykey.pem app.jar ec2-user@54.x.x.x:/home/ec2-user/
Enter fullscreen mode Exit fullscreen mode

3️⃣ Keyboard-Interactive Authentication

  • Server sends dynamic authentication prompts.

  • Commonly used for:

    • OTP verification
    • Multi-Factor Authentication (MFA)
    • Security questions

Often integrated with PAM modules in Linux systems.


4️⃣ Biometric Authentication

Uses biological traits for verification:

  • Fingerprint

  • Face recognition

  • Iris scan

✅ Very strong authentication

❌ Requires specialized hardware

Usually combined with password or token for added security.


5️⃣ Token-Based Authentication

Uses a token to authenticate the user instead of (or in addition to) a password.

A token can be:

  • 🔑 Hardware token (USB security key, smart card)

  • 📱 Software token (OTP from mobile app)

  • 🧾 Time-based OTP (like Google Authenticator)

How It Works:

  1. User enters credentials (or initiates login).

  2. System requests a token.

  3. User provides:

* OTP generated by device/app  
    OR

* Inserts hardware security key.
Enter fullscreen mode Exit fullscreen mode
  1. Server verifies the token before granting access.

✅ Strong security

✅ Protects against password theft

✅ Commonly used in MFA systems

Top comments (0)