SSH Key Authentication & the Config File
Set up passwordless SSH using key pairs and streamline connections with a personal SSH config file.
SSH Key Authentication & the Config File is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Key-Based Authentication?
SSH keys replace passwords with a cryptographic key pair. They are more secure and enable passwordless, automatable logins.
- Private key stays on your machine
- Public key is copied to the server
Generating a Key Pair
Use ssh-keygen to create a modern Ed25519 key pair. It produces a private key and a matching .pub public key.
ssh-keygen -t ed25519 -C "you@example.com"Where Keys Are Stored
By default keys live in ~/.ssh/. The private key must stay secret; the public key can be shared.
ls -l ~/.ssh/Copying the Public Key to a Server
ssh-copy-id appends your public key to the server authorized_keys in one step.
ssh-copy-id user@server.example.comManual Key Installation
If ssh-copy-id is unavailable, append the public key manually to the remote authorized_keys file.
cat ~/.ssh/id_ed25519.pub | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Correct Permissions Matter
SSH refuses keys with loose permissions. The .ssh directory should be 700 and key files 600.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519Connecting with Your Key
Once the public key is installed, ssh user@host logs in without a password. Use -i to pick a specific key.
ssh -i ~/.ssh/id_ed25519 user@server.example.comProtecting Keys with a Passphrase
A passphrase encrypts the private key on disk. The ssh-agent caches it so you type it only once per session.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519The SSH Config File
~/.ssh/config stores per-host settings so you can connect with a short alias instead of long command lines.
# ~/.ssh/config
Host web
HostName 203.0.113.10
User deploy
Port 2222
IdentityFile ~/.ssh/id_ed25519Connecting via a Config Alias
With the block above, ssh web applies all those options automatically.
ssh webUseful Config Options
The config file supports many options, such as keeping connections alive.
ServerAliveInterval 60keeps idle sessions openForwardAgent yesforwards your agent
Host *
ServerAliveInterval 60
ServerAliveCountMax 3Quick Check
Test your SSH key knowledge.
Recap
You set up secure SSH access:
- Generate a pair with
ssh-keygen -t ed25519 - Install the public key via
ssh-copy-id - Lock down permissions (700/600)
- Simplify logins with
~/.ssh/confighost aliases
Frequently asked questions
Is the “SSH Key Authentication & the Config File” lesson free?
Yes — the full text of “SSH Key Authentication & the Config File” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “SSH Key Authentication & the Config File”?
Set up passwordless SSH using key pairs and streamline connections with a personal SSH config file. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “SSH Key Authentication & the Config File” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Basic Network Utilities (ping, ip, netstat)
- Secure Shell (SSH) Fundamentals
- SCP and Rsync for File Transfers
- SSH Key Authentication & the Config File