Skip to the content.

đź”— Link to the Room

🏷️ Table of Contents

  1. Chapter 3 Quiz
  2. GNU Privacy Guard
    2.1 Pretty Good Privacy (PGP)
    2.2 How PGP encryption works (step by step)
    2.3 GNU Privacy Guard (GPG)
    2.4 Creating GPG keys
  3. Encrypting Your Files
    3.1 Symmetric Encryption (password-based)
    3.2 Decrypting
    3.3 Asymmetric Encryption (key-based)
    3.4 Sharing public keys
    3.5 Encrypting a file for someone else
    3.6 Decrypting the file
  4. SSH Protocol 1
  5. Creating an SSH Key Set
    5.1 Generating SSH keys
    5.2 Copying your public key to a remote server
  6. Disable Username and Password SSH Login
  7. X11 Forwarding and SSH Tunneling
    7.1 Turn off X11 Forwarding
    7.2 SSH Tunneling
  8. Improving SSH Logging
  9. Chapter 4: Mandatory Access Control
  10. Introduction to AppArmor
    10.1 AppArmor Configuration
    10.2 Adding More Profiles
  11. AppArmor Command Line Utilities
    11.1 AppArmor Modes
    11.2 AppArmor Command-Line Utilities
  12. Chapter 4 Quiz
  13. Chapter 3: SSH and Encryption

📚 Study Notes

[!NOTE] All tasks for this room were completed using Ubuntu 18.04 LTS. That being said, pretty much everything that applies to 18.04 can apply to 20.04 as well. If you take what you learn out of this room and try to apply it in the real world for practice and fun and something does not work, be sure to check the documentation for what you are trying to do.

Chapter 3 Quiz


❓Which SSH Protocol version is the most secure?2

❓This is a random, arbitrary number, used as the session key, that is used to encrzpt GPG.nonce

❓Yey/Ney - GPG is based on the OpenPGP standardYey

❓What is the command to symmetrically encrypt a file with GPG?gpg -c

❓What is the command to asymmetrically encrypt a file with GPG?gpg -e

❓What is the command to create SSH keys?ssh-keygen

❓Where are ssh keys stored in a user's home directory?.ssh

❓What option needs to be set to select the type of key to generate for SSH?-t

❓The SSH configuration options presented in this chapter were found in what file (full path)?/etc/ssh/sshd_config

GNU Privacy Guard

Pretty Good Privacy (PGP)

How PGP encryption works (step by step)

  1. You write an email
  2. A random one-time session key is created (This is also called a nonce)
  3. The email is encrypted using this session key
  4. The session key itself is encrypted using the recipient’s public key
  5. Both the encrypted email and encrypted session key are sent

To decrypt:

  1. The recipient uses their private key to unlock the session key
  2. The session key is then used to decrypt the message back to readable text

GNU Privacy Guard (GPG)

Creating GPG keys

Encrypting Your Files

1. Symmetric Encryption (password-based)

[!IMPORTANT] This passphrase is not your GPG key passphrase GPG may leave the original file unencrypted You should delete it using rm or shred if it’s sensitive

Decrypting

2. Asymmetric Encryption (key-based)

[!IMPORTANT] Public keys can be shared Private keys must NEVER be shared

3. Sharing public keys

4. Encrypting a file for someone else

Example

5. Decrypting the file

[!NOTE] Symmetric encryption is simple and fast, but requires sharing a secret Asymmetric encryption is more secure and scalable GPG allows safe file sharing without exchanging passwords Private keys are extremely sensitive — protect them at all costs

SSH Protocol 1

Creating an SSH Key Set

Generating SSH keys

image

[!IMPORTANT] Public key = shared with the server Private key = never share

Copying your public key to a remote server

[!IMPORTANT] SSH keys = safer than passwords Always protect your private key Share only your public key Use modern algorithms (RSA ≥3072 or ECDSA ≥384) for stronger security Correct permissions on .ssh and authorized_keys are critical

Disable Username and Password SSH Login

X11 Forwarding and SSH Tunneling

Turn off X11 Forwarding

SSH Tunneling

image

[!NOTE] X11 Forwarding - disable unless you really need GUI over SSH SSH Tunneling - disable to prevent unauthorized network access Both settings improve SSH security on your server.

Improving SSH Logging

image

Chapter 4: Mandatory Access Control

Introduction to AppArmor

AppArmor Configuration

Adding More Profiles

[!IMPORTANT] AppArmor lets you control program access with reusable, understandable profiles while making custom hardening easier than SELinux.

AppArmor Command Line Utilities

AppArmor Modes

AppArmor Command-Line Utilities

[!IMPORTANT] AppArmor profiles define rules for programs Modes control how strict these rules are Command-line utilities let you enforce, audit, complain, or disable profiles Always check status after changes with aa-status

Chapter 4 Quiz


❓Where are the AppArmor profiles located?/etc/apparmor.d

❓This directory includes partial profiles to be used in your own custom profilesabstractions

❓This punctuation mark is REQUIRED at the end of every rule in a profile.

❓This AppArmor mode enforces the profiles but also logs themaudit

❓This command checks the status of AppArmoraa-status

Chapter 3: SSH and Encryption

[!IMPORTANT] Encryption is a core skill for security and privacy.