DevOps.Academy
CoursesCurriculumInterview prepPricing
◔My learningSign in
DevOps.Academy

Free, hands-on DevOps lessons. Made with care in India.

System status

Learn

All coursesLinux roadmapCurriculumInterview questionsCheat sheetsMy learning

Academy

PricingCertificates

Legal

PrivacyTermsContact

devops.rajeev.pro

NetworkingLesson 10 of 12
Your progress · 0%
On this page
  1. Keys and agents
  2. SSH config
  3. Tunnels and port forwarding
  4. Bastions and VPNs
↖ Course roadmap
Lesson 10 · SSH and remote access

SSH and remote access: reach servers safely

Authenticate with SSH keys, keep host identity checks, simplify connections with ssh_config, and forward a private port through a trusted jump host.

24 min read · beginner · hands-on

By the end of this lesson you'll be able to

0 of 4 complete
Lab status

Verified lab: generated an Ed25519 key pair, trusted the temporary server's host key, and authenticated to an OpenSSH server inside one alpine:3.22 container. The fingerprint and root output are real. The container removes both keys when it exits.
Cloud lab: none. No remote or cloud account was accessed.

Before SSH, engineers often exposed a shared password or copied credentials between servers. That made access hard to audit and leaks hard to contain. SSH encrypts the session and uses keys to prove client and server identity. Config aliases and tunnels reduce repeated typing without moving the private service onto the public internet. In this lesson, you will inspect a key login, configure a host, and trace a tunnel.

Keys and agents

SSH uses two different key pairs. Your user key authenticates you: the private half stays on your client, and the public half goes in the server account's ~/.ssh/authorized_keys. The server's host key identifies the server to you. Check and retain its fingerprint through a trusted channel before accepting a first connection.

ssh-agent holds unlocked private keys in memory for your login session. ssh-add loads a key so you do not enter its passphrase for every connection. The agent does not send your private key over the network. Avoid agent forwarding to machines you do not trust; someone with access to the forwarded socket may ask the agent to sign.

Inspect a public-key fingerprint before you install it:

ssh-keygen -lf /tmp/lesson-key.pub

The disposable lab runs this command and prints the real fingerprint.

SSH config

~/.ssh/config stores connection options under a host alias. SSH matches the command-line name to Host, then uses its HostName, User, and key settings. ProxyJump opens a connection through a bastion without copying your user key to that host.

Host web-prod
  HostName 203.0.113.10
  User deploy
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes
  ProxyJump bastion

203.0.113.10 is a documentation-only example address. Replace it with a server you control. Keep StrictHostKeyChecking enabled. Turning it off hides unexpected host-key changes instead of fixing them.

Tunnels and port forwarding

Local forwarding makes a local port lead to a destination reachable from the SSH server:

ssh -N -L 15432:db.internal:5432 bastion

Here 15432 is on your machine; db.internal:5432 is reached from the bastion. -N asks SSH not to start a remote shell. Your database client then connects to localhost:15432. The tunnel encrypts the path to the bastion, but database authentication and TLS still matter.

Bastions and VPNs

A bastion is a tightly controlled host used as a jump point into a private network. A VPN creates a routed network path from a client or site to that private network. Use a bastion for a narrow administrative hop; use a VPN when approved users need broader access to multiple internal services.

Do not expose a database port to make SSH forwarding work. Restrict the bastion's inbound sources, keep access logged, and patch it. A jump host is still a server and a security boundary, not a reason to trust every machine behind it.

⌘
Mini mission

Prove key authentication

Generate a temporary key, add its public half to a disposable OpenSSH server, verify the host key, then connect. The container removes all temporary key material.

Input: DockerOutput: A real key fingerprint and the authenticated account name
Reveal one safe solution
bash devops-academy-tools/networking-lab/10-capture.sh

Read the script before running it. It generates both host and user keys inside the temporary container and uses a known-hosts file instead of disabling host verification.

Try it yourself

0 of 4 steps done

Run each task in your own account or terminal, then tick it off.

Knowledge check

Quick check

Question 1 of 3

Which key should be installed in a server user's authorized_keys file?

Go deeper

Official reading for this lesson

  • Docsssh(1)OpenBSD manual pages ↗
  • Docsssh_config(5)OpenBSD manual pages ↗
  • Docsssh-agent(1)OpenBSD manual pages ↗

Or get every quiz answer right and it completes itself.

Something unclear, wrong or out of date in this lesson? Tell me, and I'll fix it.

← PreviousProxies and load balancing: one front doorNext lesson →Container networking: bridges, namespaces and Pods