Skip to content
Tutorials Center
My learning

Topics

Lesson 38 of 80 ยท Network Security

VPNs, Wi-Fi and Remote Access Security

Learn how VPNs (IPsec and WireGuard) work, how WPA3 secures Wi-Fi, and how to harden SSH with keys, jump hosts and a config auditor for remote access.

People rarely work inside one building anymore. Staff connect from homes and cafes, administrators reach servers across the internet, and devices join wireless networks nobody fully controls. Every one of these links crosses a network you do not trust, so the question is how to make the link itself safe: who is on the other end, and can anyone in between read or change the traffic?

Three technologies answer it. VPNs build an encrypted tunnel across an untrusted network, WPA2/WPA3 protect the wireless hop, and SSH gives administrators a secure remote shell. This lesson explains how each works and how to configure it safely. The cryptography underneath was introduced in Public-Key Cryptography and TLS, Certificates and PKI. The sandbox here cannot run VPNs or Wi-Fi gear, so the configuration examples are read-only, followed by a runnable audit tool.

What a VPN does, and what it does not

A virtual private network wraps your packets inside an encrypted, authenticated outer packet and sends them to a VPN gateway, which unwraps them and forwards them. Observers on the path, such as the cafe Wi-Fi or your ISP, see only an encrypted stream to the gateway. There are two common uses:

  • Remote access: an individual device connects to the company network.
  • Site-to-site: two networks (two offices, or an office and a cloud network) are joined permanently.
flowchart LR
    L["Laptop at a cafe"] -- "encrypted tunnel<br/>over the internet" --> G["VPN gateway"]
    G --> N["Company network<br/>or internet exit"]
    X(("Observer on<br/>cafe Wi-Fi")) -. "sees only ciphertext" .-> L

The tunnel protects the untrusted stretch between the laptop and the gateway, not what happens after the gateway.

Be realistic about the limits. A VPN does not make you anonymous: the VPN operator sees your traffic, and websites still see you through cookies and accounts. It does not remove malware. And a consumer VPN merely moves trust from your ISP to the VPN company. A corporate VPN also places the remote device on the internal network, so a compromised laptop becomes an inside attacker, which is one reason zero trust access (Firewalls, Segmentation and Zero Trust) is replacing broad VPN access with per-application access.

IPsec and WireGuard

IPsec is a suite of standards that operates at the IP layer and is built into many systems and routers, and it is the traditional choice for site-to-site links. It works in two phases. First, IKE (Internet Key Exchange) authenticates both sides, using certificates or a pre-shared key, and agrees on keys through a Diffie-Hellman exchange. Second, data travels in ESP (Encapsulating Security Payload) packets, which provide encryption and integrity. In tunnel mode the entire original packet is wrapped, which is what VPNs use. IPsec is flexible but complex, with many options, so misconfiguration (old algorithms, weak shared keys) is the usual weakness.

WireGuard takes the opposite approach: a small codebase and a fixed, modern set of cryptographic choices (Curve25519 for key exchange, ChaCha20-Poly1305 for encryption, BLAKE2s for hashing). There is nothing to negotiate, which removes whole classes of mistakes. Each peer has a key pair, and configuration is mostly a list of peers and the address ranges each one may use. A minimal read-only example:

INI
# /etc/wireguard/wg0.conf on the server (keys shortened)
[Interface]
Address    = 10.8.0.1/24
ListenPort = 51820
PrivateKey = <server private key>

[Peer]
# Alice's laptop
PublicKey  = <alice public key>
AllowedIPs = 10.8.0.2/32

AllowedIPs does double duty: it is a routing table (what to send to this peer) and an access filter (what source addresses are accepted from it). Giving each peer only its own /32 stops one client from impersonating another. Other options you may meet are OpenVPN (TLS-based, widely supported) and SSL/TLS VPN portals reachable from a browser.

Good VPN practice:

  • Require multi-factor authentication to connect (Multi-Factor Authentication and Passkeys).
  • Use modern algorithms and certificates or per-user keys, never one shared password for everybody.
  • Choose split tunneling deliberately: sending only company traffic through the tunnel saves bandwidth, but sending everything lets the company filter and log. Either is a policy decision.
  • Check device health before allowing access, patch the VPN gateway quickly (internet-facing VPN appliances are a favorite target), and log connections.
  • Give VPN users only the network access they need, not the whole internal range.

Wi-Fi security

Wireless signals pass through walls, so anyone nearby can capture them. Encryption is therefore mandatory.

Standard Status Notes
Open (no password) Unsafe Everything is visible to others in range (WPA3 adds opportunistic encryption, called OWE, for open networks)
WEP Broken Can be cracked in minutes; never use
WPA / WPA2-TKIP Obsolete Replace
WPA2-AES (CCMP) Acceptable Weak if the passphrase is guessable: captured handshakes can be attacked offline
WPA3 Recommended Uses SAE, a password-authenticated key exchange, so captured handshakes cannot be brute-forced offline, and adds forward secrecy

WPA3-Personal replaces the old pre-shared-key handshake with SAE (Simultaneous Authentication of Equals). Even with a short passphrase, an attacker must interact with the access point for each guess instead of testing millions of guesses per second on a stolen capture. WPA2/WPA3-Enterprise goes further: each user authenticates with their own credentials or certificate through a RADIUS server (802.1X), so there is no shared password to leak and access is removed per person.

Practical Wi-Fi hardening: use WPA3 (or WPA2-AES with a long random passphrase), turn off WPS, change default admin passwords and keep router firmware updated, put guests and IoT devices on separate VLANs, and monitor for rogue access points and "evil twins", fake networks with the same name as a real one. Hiding the network name (SSID) is not a security measure. As a user on public Wi-Fi, rely on HTTPS everywhere and a VPN if you must, and do not click through certificate warnings.

SSH hardening

SSH is the standard way to administer servers. Exposed to the internet, it is attacked constantly with automated password guessing, so how you configure it matters. The main settings live in /etc/ssh/sshd_config (read-only here):

TEXT
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
KbdInteractiveAuthentication no
MaxAuthTries 3
AllowUsers deploy admin
X11Forwarding no
ClientAliveInterval 300
ClientAliveCountMax 2

The key ideas:

  1. Use keys, not passwords. An SSH key pair has an unguessable private key held on your device (protect it with a passphrase or a hardware token) and a public key listed in ~/.ssh/authorized_keys on the server. Disable password login completely, and brute force stops being a threat.
  2. No direct root login. Log in as a named user and elevate with sudo, so actions are attributable.
  3. Restrict who may connect with AllowUsers or groups, and by firewall: allow port 22 only from known networks or only from a VPN.
  4. Verify host keys on first connection. The fingerprint you see should match one you obtained through a trusted channel; a changed host key is a warning that someone may be intercepting.
  5. Keep it patched, and consider short-lived certificates issued by an SSH certificate authority for larger fleets, which avoids keys that live forever.
  6. Moving SSH to another port only reduces log noise, it is not security. A tool that bans repeated failures (like fail2ban) helps against guessing but is secondary to disabling passwords.

Jump hosts

A jump host (or bastion host) is a hardened machine, reachable from outside, that is the only way into a private network. Administrators connect to the bastion first and from there to internal servers. The internal servers accept SSH only from the bastion's address, so there is one place to log, monitor and apply strong authentication.

flowchart LR
    A["Admin laptop"] -->|"SSH + MFA"| J["Bastion / jump host<br/>public subnet"]
    J -->|"SSH from bastion only"| S1["App server"]
    J --> S2["Database server"]
    I(("Internet")) -. "no direct SSH" .-x S1

One audited front door instead of many exposed ones.

OpenSSH can do this transparently from the client with ProxyJump (read-only):

TEXT
# ~/.ssh/config
Host bastion
    HostName bastion.example.com
    User admin
    IdentityFile ~/.ssh/id_ed25519

Host app-*
    User deploy
    ProxyJump bastion

With this, ssh app-01 hops through the bastion while the private key never leaves your laptop. Avoid agent forwarding to untrusted hosts, because it lets the remote machine use your keys while you are connected. Cloud providers also offer browser-based or agent-based session managers that remove the need for open SSH ports altogether.

Auditing a remote-access configuration

Checklists are ideal to automate. This small auditor reads an sshd_config-style text and reports the weak settings, which is the same logic that configuration scanners use.

Python An sshd_config auditor

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Wi-Fi network inventory check

The same approach works for wireless: compare what a survey sees with what you expect. The data below is fake.

Python Spotting weak and rogue Wi-Fi networks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does a VPN protect?

    A VPN encrypts the stretch between the device and the gateway. It does not anonymize you toward sites, remove malware or fix weak credentials.
  2. 2. Why is WPA3-Personal better than WPA2-Personal against offline guessing?

    In WPA2-Personal, a captured four-way handshake lets an attacker test guesses on their own hardware. SAE removes that possibility and provides forward secrecy.
  3. 3. Which sshd setting combination gives the biggest security gain against internet password guessing?

    With password login disabled, guessing passwords is pointless. Port changes only reduce noise.
  4. 4. What is the main benefit of a jump host?

    Concentrating access in one audited place reduces the exposed surface and makes logging and strong authentication easier.
  5. 5. In a WireGuard configuration, what does a peer's AllowedIPs setting control?

    AllowedIPs works as routing table and as an ingress filter, so a narrow value such as a single /32 stops a peer from spoofing other addresses.

Summary

  • A VPN builds an encrypted, authenticated tunnel across an untrusted network; it protects the link, not the endpoint, and does not guarantee anonymity.
  • IPsec is flexible and common for site-to-site links; WireGuard is small with fixed modern cryptography. Require MFA, patch gateways and limit what VPN users can reach.
  • Use WPA3 (or WPA2-AES with a strong passphrase), enterprise authentication where possible, separate guest and IoT networks and watch for rogue access points.
  • Harden SSH: keys instead of passwords, no root login, restricted users, verified host keys and a patched server.
  • Jump hosts concentrate remote administration behind one monitored door; automate configuration audits.

Next: Intrusion Detection and Network Monitoring, where you'll learn how to notice attacks that get past the preventive controls.