teluzia.Cloud Engineer · Day 12
CHAPTER 02 · LINUX ADMINISTRATION AND SHELL SCRIPTING

SSH keys and secure remote access

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Create a dedicated SSH practice key and inspect its public half without connecting to an unknown machine. Public-key authentication protects the private half locally while a server authorizes the matching public half. Host verification is a separate defense against connecting to an impostor. SSH public-key authentication uses a public key placed in the server account’s authorized_keys and a private key retained by the client. A passphrase encrypts the private-key file at rest; an agent can temporarily hold unlocked keys. Generate a dedicated key rather than overwriting an existing identity. A server grants access by accepting a public key for a particular account, subject to SSH server policy. Client and server file permissions protect key material and authorization files. A typical .ssh directory is mode 700 and a private key mode 600. These permissions do not automatically authorize a login.

Think of it this way

Your public key is an authorized lock pattern; your private key opens it; known_hosts is the building’s verified identity card.

TOPIC 01 / 03Step by step

Key pairs and passphrases

SSH public-key authentication uses a public key placed in the server account’s authorized_keys and a private key retained by the client. A passphrase encrypts the private-key file at rest; an agent can temporarily hold unlocked keys. Generate a dedicated key rather than overwriting an existing identity. ssh-keygen -t ed25519 -f ./practice_key -C "teluzia-local-practice" creates a local key pair after passphrase prompts; share only practice_key.pub. Separating public distribution from private custody avoids credential leaks and makes revocation possible by removing the specific authorized public key from a server account. Copying a private key into Git or a chat exposes authentication material; the .pub suffix matters, and passphrases do not justify publishing private files.

WORKED EXAMPLE
ssh-keygen -t ed25519 -f ./practice_key -C "teluzia-local-practice" creates a local key pair after passphrase prompts; share only practice_key.pub.
Why this matters

Separating public distribution from private custody avoids credential leaks and makes revocation possible by removing the specific authorized public key from a server account.

A common trap

Copying a private key into Git or a chat exposes authentication material; the .pub suffix matters, and passphrases do not justify publishing private files.

MAKE IT VISIBLE

Build the permission you mean

READ. WRITE. EXECUTE.

Who should be allowed to do what?

File permissions apply to the owner, group, and everyone else. Toggle a permission to see its symbolic and numeric forms.

Owner

rw-

Group

r--

Others

---
chmod 640 notes.txtrw-r-----
What this grants

Owner: read, write. Group: read. Others: no permissions. For a directory, execute means traversal; for a file, execute means permission to run it.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Key pairs and passphrases

SSH public-key authentication uses a public key placed in the server account’s authorized_keys and a private key retained by the client. A passphrase encrypts the private-key file at rest; an agent can temporarily hold unlocked keys. Generate a dedicated key rather than overwriting an existing identity. ssh-keygen -t ed25519 -f ./practice_key -C "teluzia-local-practice" creates a local key pair after passphrase prompts; share only practice_key.pub. Separating public distribution from private custody avoids credential leaks and makes revocation possible by removing the specific authorized public key from a server account. Copying a private key into Git or a chat exposes authentication material; the .pub suffix matters, and passphrases do not justify publishing private files.

WORKED EXAMPLE
ssh-keygen -t ed25519 -f ./practice_key -C "teluzia-local-practice" creates a local key pair after passphrase prompts; share only practice_key.pub.

Why this matters

Separating public distribution from private custody avoids credential leaks and makes revocation possible by removing the specific authorized public key from a server account.

A common trap

Copying a private key into Git or a chat exposes authentication material; the .pub suffix matters, and passphrases do not justify publishing private files.

Server authorization and file permissions

A server grants access by accepting a public key for a particular account, subject to SSH server policy. Client and server file permissions protect key material and authorization files. A typical .ssh directory is mode 700 and a private key mode 600. These permissions do not automatically authorize a login. Use chmod 600 practice_key and ssh-keygen -lf practice_key.pub to inspect a fingerprint; authorization requires a matching public key on an actual server account. Understanding both client custody and server authorization prevents confusing a valid local key with permission to enter any host or any account across a network. Repairing authentication by making key files world-readable weakens security and can make SSH reject them; diagnose account, public-key placement and restrictive permissions separately instead.

WORKED EXAMPLE
Use chmod 600 practice_key and ssh-keygen -lf practice_key.pub to inspect a fingerprint; authorization requires a matching public key on an actual server account.

Why this matters

Understanding both client custody and server authorization prevents confusing a valid local key with permission to enter any host or any account across a network.

A common trap

Repairing authentication by making key files world-readable weakens security and can make SSH reject them; diagnose account, public-key placement and restrictive permissions separately instead.

Host verification and remote access

SSH encrypts transport and authenticates the remote host using its host key. On first connection, verify the presented fingerprint using a trusted independent channel. known_hosts remembers that identity; a changed key can mean legitimate replacement or an attack. Do not disable host-key checking to silence a warning. For a controlled server, compare ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on its trusted console with the client’s displayed fingerprint before accepting the first connection. Host verification complements user authentication by proving who receives your encrypted session, reducing the risk of sending commands or credentials to an impersonating server unknowingly. Deleting known_hosts entries automatically after a warning discards security evidence; verify the actual host-key change through a trusted channel before updating the saved identity.

WORKED EXAMPLE
For a controlled server, compare ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on its trusted console with the client’s displayed fingerprint before accepting the first connection.

Why this matters

Host verification complements user authentication by proving who receives your encrypted session, reducing the risk of sending commands or credentials to an impersonating server unknowingly.

A common trap

Deleting known_hosts entries automatically after a warning discards security evidence; verify the actual host-key change through a trusted channel before updating the saved identity.

KEEP THESE WITH YOU

Today’s takeaways

Keep private keys private and permission-restricted.

Authorize keys for specific server accounts.

Verify host identity independently.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed