ๆƒฏๆ€ง่šๅˆ ้ซ˜ๆ•ˆ่ฟฝ่ธชๅ’Œ้˜…่ฏปไฝ ๆ„Ÿๅ…ด่ถฃ็š„ๅšๅฎขใ€ๆ–ฐ้—ปใ€็ง‘ๆŠ€่ต„่ฎฏ
้˜…่ฏปๅŽŸๆ–‡ ๅœจๆƒฏๆ€ง่šๅˆไธญๆ‰“ๅผ€

ๆŽจ่่ฎข้˜…ๆบ

ๅฐไผ—่ฝฏไปถ
ๅฐไผ—่ฝฏไปถ
C
Check Point Blog
Vercel News
Vercel News
Y
Y Combinator Blog
G
Google Developers Blog
P
Proofpoint News Feed
WordPressๅคงๅญฆ
WordPressๅคงๅญฆ
MongoDB | Blog
MongoDB | Blog
ๅš
ๅšๅฎขๅ›ญ - ๅธๅพ’ๆญฃ็พŽ
Last Week in AI
Last Week in AI
ๅš
ๅšๅฎขๅ›ญ - ใ€ๅฝ“่€็‰นใ€‘
N
Netflix TechBlog - Medium
L
LangChain Blog
V
V2EX
้’›ๅช’ไฝ“๏ผšๅผ•้ข†ๆœชๆฅๅ•†ไธšไธŽ็”Ÿๆดปๆ–ฐ็Ÿฅ
้’›ๅช’ไฝ“๏ผšๅผ•้ข†ๆœชๆฅๅ•†ไธšไธŽ็”Ÿๆดปๆ–ฐ็Ÿฅ
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
D
DataBreaches.Net
ๅš
ๅšๅฎขๅ›ญ_้ฆ–้กต
B
Blog RSS Feed
The Cloudflare Blog
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Donโ€™t Fail โ€” They Drift Spilling beans for how i learn for exam๐Ÿ˜"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" โ€” What Actually Happened Comfy Cloudโ€™s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions โ€” here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components โ€” Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cรณmo construรญ un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 ๐Ÿš€ I Built an Ethical Hacking Scanner Tool โ€“ Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points โ€” Here's What I Found About How Markets Really Move EcoTrack AI โ€” Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
# Real-World SSH: From Your Laptop to the Linux Kernel ๐Ÿš€
Mh Asif Kamal ยท 2026-06-26 ยท via DEV Community

Mh Asif Kamal

If you work in tech, you use SSH every day. But for a lot of developers, it's just a black box. Letโ€™s pull back the curtain and trace a real-world hands-on sequence on an Ubuntu server to see exactly how the network handoff and Linux PAM (Pluggable Authentication Modules) pipeline work under the hood.


1. The Core Concept: Public vs. Private Keys

Instead of using passwords, secure modern SSH relies on asymmetric cryptography:

  • The Public Key: Think of this like a padlock. You can hand it out to anyone or leave it on a public server. It doesn't matter who sees it.
  • The Private Key: This is the physical key that opens the padlock. It stays safely on your laptop, and you never share it.

2. Hands-On: Solving "Permission Denied" in Real-Time ๐Ÿ› ๏ธ

Step 1: The Error

Connecting to a cloud instance without an authorized key fails immediately:

mhasifkamal@Mhs-MacBook-Air work % ssh mhasifkamal@34.131.76.231
mhasifkamal@34.131.76.231: Permission denied (publickey).

Step 2: Generating the Match

Run ssh-keygen. On modern operating systems, it automatically defaults to the highly secure ED25519 algorithm:

mhasifkamal@Mhs-MacBook-Air work % ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/mhasifkamal/.ssh/id_ed25519): ssh_key
Your identification has been saved in ssh_key
Your public key has been saved in ssh_key.pub

Step 3: Verifying the Files

Your system sets strict, private read/write privileges (-rw-------) for the private key, while leaving the .pub lock file readable:

mhasifkamal@Mhs-MacBook-Air work % ls -l
-rw-------  1 mhasifkamal  staff  432 Jun 25 21:42 ssh_key
-rw-r--r--  1 mhasifkamal  staff  115 Jun 25 21:42 ssh_key.pub

mhasifkamal@Mhs-MacBook-Air work % cat ssh_key.pub 
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFHgEWeyk6UwHRs4VknwryjptBQcG/dYufjCJu8oq+Qe...

Step 4: The Payoff

Point directly to your private key file using the -i flag to unlock entry:

mhasifkamal@Mhs-MacBook-Air work % ssh -i ssh_key mhasifkamal@34.131.76.231 
Welcome to Ubuntu 24.04.4 LTS (GNU/Linux 6.17.0-1018-gcp x86_64)
mhasifkamal@instance-20260620-113027:~$ 


3. Where the Lock Lives ๐Ÿ“‚

Once you log in, navigate to your home directory's hidden .ssh folder. All authorized locks are stored in a single text file:

mhasifkamal@instance-20260620-113027:~$ cd .ssh/
mhasifkamal@instance-20260620-113027:~/.ssh$ ls
authorized_keys
mhasifkamal@instance-20260620-113027:~/.ssh$ sudo vi authorized_keys 

Cloud setup panels and commands like ssh-copy-id simply append your public key string into this authorized_keys file.


4. Toggling Passwords & The Cloud Override Trap ๐Ÿ•ธ๏ธ

Let's create a traditional password user named test-user on the server:

mhasifkamal@instance-20260620-113027:~/.ssh$ sudo adduser test-user
New password: 
passwd: password updated successfully

Trying to log in immediately from your laptop will still fail:

mhasifkamal@Mhs-MacBook-Air work % ssh test-user@34.131.76.231
test-user@34.131.76.231: Permission denied (publickey).

The Fix

To allow temporary password logins, you must modify the incoming SSH daemon settings. Avoid ssh_config (which handles outbound client connections) and focus on the drop-in cloud override files inside /etc/ssh/sshd_config.d/:

mhasifkamal@instance-20260620-113027:/etc/ssh$ ls /etc/ssh/sshd_config.d/
50-cloudimg-settings.conf  60-cloudimg-settings.conf

Open these overrides, change the parameter to yes, and restart the daemon:

sudo vi /etc/ssh/sshd_config.d/*
# Set: PasswordAuthentication yes

sudo systemctl restart ssh

Now, the server prompts for the password and allows authentication cleanly:

mhasifkamal@Mhs-MacBook-Air work % ssh test-user@34.131.76.231
test-user@34.131.76.231's password: 
Welcome to Ubuntu 24.04.4 LTS!

5. Under the Hood: The Complete Architecture Flow ๐Ÿ”„

Here is exactly how the network handoff transitions directly into Linux's internal PAM (Pluggable Authentication Modules) pipeline:

[ LAPTOP ]                                                [ UBUNTU SERVER ]
    โ”‚                                                            โ”‚
    โ”œโ”€โ”€โ”€ 1. Protocol Handshake (Agree on SSH versions) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚
    โ”‚                                                            โ”‚
    <โ”€โ”€โ”€ 2. Diffie-Hellman Key Exchange (Secure Tunnel Built) โ”€โ”€>โ”‚
    โ”‚                                                            โ”‚
    <โ”€โ”€โ”€ 3. Asymmetric Key Challenge (Puzzle sent to client) โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                            โ”‚
    โ”œโ”€โ”€โ”€ 4. Challenge Solved (Proof verified by sshd) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚
    โ”‚                                                            โ”‚
    โ”‚                                                   [ Hand-off to PAM Engine ]
    โ”‚                                                            โ”‚
    โ”‚                                                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                   โ”‚  /etc/pam.d/    โ”‚
    โ”‚                                                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                                                            โ”‚
    โ”‚                                                   ๐Ÿ”’ 1. common-auth
    โ”‚                                                      (Checks credentials via pam_unix.so)
    โ”‚                                                            โ”‚
    โ”‚                                                   ๐Ÿ“‹ 2. common-account
    โ”‚                                                      (Checks password expiration/locks)
    โ”‚                                                            โ”‚
    โ”‚                                                   ๐Ÿ› ๏ธ 3. common-session
    โ”‚                                                      (Sets env, umask, & log limits)
    โ”‚                                                            โ”‚
    <โ”€โ”€โ”€ 5. Shell Opened (PTY Allocated to user) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The PAM Blueprint

Modern Linux environments manage application access dynamically via files in /etc/pam.d/. (The old master file /etc/pam.conf is ignored).

When we look inside the system authentication rules (cat /etc/pam.d/common-auth), we see the literal logical circuit board:

auth    [success=1 default=ignore]      pam_unix.so nullok
auth    requisite                       pam_deny.so
auth    required                        pam_permit.so

  • pam_unix.so: Checks credentials against system hashes. If successful, [success=1] jumps past the next line.
  • pam_deny.so: The trap line. If your credentials fail, PAM stops here, breaks the circuit, and kicks you out with a Permission denied error.
  • pam_permit.so: The green light. Passes a success flag back to the environment, allowing common-session to spin up your environment variables and launch your bash or zsh shell.

Wrap Up ๐ŸŽฏ

SSH builds the secure tunnel across the web, but PAM controls your access rights once you cross the threshold. Hardening your server by setting your drop-in configs back to PasswordAuthentication no keeps the automated brute-force bots completely out of your architecture.

What does your local ~/.ssh/config file look like? Let's chat in the comments! ๐Ÿ‘‡

#sre #ssh #linux #devops #security #sysadmin #tutorial