# SSH, Bastions and VPNs

> Access remote machines and private networks securely using SSH keys, jump hosts, tunnels and modern VPNs. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/ssh-vpn
Last updated: 2026-11-28

Access remote machines and private networks securely using SSH keys, jump hosts, tunnels and modern VPNs.

Intermediate · about 4 hours · difficulty 2/5

Learn first: [Firewalls, Security Groups and NAT](https://www.internhack.in/roadmaps/tracks/devops/firewalls-nat)

SSH is how you reach servers, and VPNs are how you reach private networks. Both need to be set up securely because they are the front door for attackers too.

### SSH done right

- Use **key-based auth** (`ssh-keygen -t ed25519`), disable password login and root login in `sshd_config`.
- An **ssh-agent** holds unlocked keys; agent forwarding is convenient but risky on shared hosts.
- `~/.ssh/config` with `Host`, `User`, `IdentityFile` and `ProxyJump` makes access to many hosts painless.
- **Tunnels**: local forward (`-L 5432:db:5432`) to reach a private database, remote forward (`-R`), and dynamic SOCKS (`-D`).
- `scp`, `rsync -avz` and `sftp` for files.

### Reaching private networks

- **Bastion (jump) hosts** as the single hardened entry point.
- Keyless alternatives: AWS Systems Manager Session Manager, GCP IAP, Azure Bastion, or SSH certificates from a CA.
- **VPNs**: WireGuard (simple, fast), OpenVPN, IPsec for site-to-site, and mesh VPNs like Tailscale.

### Pitfalls

Sharing one private key across a team, leaving old public keys in `authorized_keys`, and bastions with open-to-the-world SSH and no logging.

**Good enough to move on:** you can reach a database in a private subnet through a jump host with one `ssh` command, and explain why session managers are replacing bastions.

## Key concepts

- **Key-based auth and sshd hardening**
- **ssh config and ProxyJump**
- **Port forwarding and tunnels**
- **rsync and scp**
- **Bastion hosts**
- **Session Manager / IAP**
- **WireGuard and OpenVPN**
- **SSH certificates**

## Mini project

Set up two VMs where only one has a public IP, configure ProxyJump in ~/.ssh/config to reach the private one, and open a local tunnel to a database running on it.

## Check yourself

Why is ssh agent forwarding to a shared bastion considered risky, and what does ProxyJump do differently?

## Free resources

- [OpenSSH manual pages](https://www.openssh.com/manual.html) (OpenBSD)
- [WireGuard](https://www.wireguard.com/) (wireguard.com)

Previous: [Firewalls, Security Groups and NAT](https://www.internhack.in/roadmaps/tracks/devops/firewalls-nat) · Next: [Git Fundamentals](https://www.internhack.in/roadmaps/tracks/devops/git-fundamentals)

## More in Networking You Will Actually Debug

- [How the Internet Works: TCP/IP and the OSI Model](https://www.internhack.in/roadmaps/tracks/devops/internet-tcpip)
- [DNS in Practice](https://www.internhack.in/roadmaps/tracks/devops/dns)
- [HTTP and HTTPS](https://www.internhack.in/roadmaps/tracks/devops/http-https)
- [TLS and Certificates](https://www.internhack.in/roadmaps/tracks/devops/tls-certificates)
- [Load Balancing and Proxies](https://www.internhack.in/roadmaps/tracks/devops/load-balancing-proxies)
- [Firewalls, Security Groups and NAT](https://www.internhack.in/roadmaps/tracks/devops/firewalls-nat)
- [SSH, Bastions and VPNs](https://www.internhack.in/roadmaps/tracks/devops/ssh-vpn)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
