Bastion host best practices that hold up
A bastion host is the one server that the internet can reach, and admins use it to get to all private servers. This guide shows how to harden a jump box, where the design falls short, and how to give access with no inbound port.
One door from the internet
The bastion host is the only server with a public IP address and an open SSH port.
The firewall limits the source
A firewall rule accepts SSH from known addresses and refuses all other addresses.
Logs leave the host
The bastion host sends each session record to a different server, so an attacker cannot erase it.
The second hop is private
Private servers accept SSH from the bastion host only. They have no public IP address.
What a bastion host is
A bastion host is a server that sits at the edge of a private network. It has a public IP address and one open port, usually TCP 22 for SSH. People also call it a jump box, a jump server, or a jump host.
An admin connects to the bastion host first. From there, the admin opens a second SSH session to a private server. The private servers have no public IP address, and they accept SSH from the bastion host only.
The idea is to make the attack surface small. You defend one server with great care, and you keep all other servers off the internet.
A bastion host is a good step up from a public IP address on each server. It is also a single point that all attackers can find, so the quality of its configuration decides the security of the full network.
Bastion host best practices
These bastion host best practices apply to any cloud and any Linux distribution.
Reduce the host
- Give the host one job. Install the SSH server and nothing else. Do not run a web server, a database, or a build tool on a jump box.
- Apply patches fast. Turn on automatic security updates. Rebuild the host from a clean image on a schedule.
- Restrict the source IP addresses. Accept TCP 22 from the office and from known addresses only. Do not accept
0.0.0.0/0.
Control the keys
- Disable password sign-in. Use SSH keys only, and do not let the root user sign in.
- Give each person their own account and key. A shared key hides who did what.
- Require MFA. Add a second factor to the SSH sign-in, or use hardware keys.
- Do not use SSH agent forwarding. A person with root on the bastion host can use a forwarded agent to sign in as you. Use
ProxyJumpas an alternative. WithProxyJump, the private key and the agent stay on the laptop. - Keep no private keys on the host. A key on the jump box is a key for the attacker who gets in.
Record and review
- Send logs to a different server. Record each sign-in and each session. An attacker with root can change local logs.
- Set alerts. Alert on a sign-in from a new address, and on many failed attempts.
- Remove access on the last day. Delete the account and the public key of each person who leaves.
Where a bastion host falls short
A hardened jump box still has limits that no configuration removes.
An open inbound port
The bastion host must accept connections from the internet. Scanners find an open SSH port in minutes. A flaw in the SSH server, or one stolen key, gives an attacker a position inside your network.
One shared hop
All admins go through one host. If the host stops, nobody can reach a server during the incident. If you add a second host, you have two hosts to patch and two places for keys.
Lateral movement
A session on the bastion host can usually reach every private server on port 22. The network does not know which servers a person needs. A contractor who needs one server can try all of them.
Key sprawl
Each person has a key on the bastion host and on each server. The list of authorized_keys files grows with each new person and each new server. Old keys stay in place because nobody is sure which keys are in use.
SSH only
A bastion host works well for SSH. Access to a database, an internal web app, or a Windows desktop needs a tunnel through the SSH session. Each person must set up that tunnel.
Access with no inbound port
The most common bastion host alternative turns the connection around. A small agent inside the private network makes an outbound connection to a broker. The network accepts no inbound connection from the internet.
The user signs in with an identity provider, not with a key on a shared host. The broker checks a rule for that user and that destination. If the rule permits the connection, the user and the agent set up an encrypted tunnel.
This design changes three things:
- No public SSH port. A scanner finds nothing, because nothing listens on a public address.
- A rule for each destination. A person reaches the servers in their rule, and no other server.
- Identity in place of key copies. When a person leaves the directory, the access stops.
People call this design zero trust network access. A cloud session manager and an overlay network use the same outbound idea in different ways.
How Firezone replaces a bastion host
Firezone is an open source zero trust access platform built on WireGuard. You run a Gateway in the private network. Firezone runs the control plane.
The Gateway makes outbound connections only. It needs no public IP address and no inbound firewall rule, so there is no public SSH port. The list of ports shows the outbound connections that a Gateway needs.
- You deploy a Gateway on a Linux host in the private network.
- You add a Resource for a server, a subnet, or a DNS name.
- You add a traffic restriction to the Resource, for example TCP/22 only.
- You write a Policy that gives one Group access to that one Resource.
Access is default-deny. A person who has a Policy for one server cannot reach the server next to it. The Client and the Gateway encrypt traffic end to end with WireGuard, and Firezone cannot decrypt it.
The SSH server on each host still authenticates the user. Firezone decides which hosts a person can reach on the network, and it does not manage SSH keys or SSH certificates. You continue to use your current keys, and you can remove the jump box.
For more than one Gateway in a network, put two or more Gateways in one Site. If a Gateway stops, the Client moves to a healthy Gateway.
Bastion host, legacy VPN, and Firezone
Each approach puts the control in a different place. A bastion host controls one SSH hop. A legacy VPN controls a network. Firezone controls each Resource.
| Bastion host | Legacy VPN | Firezone | |
|---|---|---|---|
| Inbound port open to the internet | TCP 22 on the bastion host | The VPN port on the VPN gateway | None |
| Private servers stay off the internet | Yes | Yes | Yes |
| A rule for each server or service | PartialNeeds a firewall rule for each server | PartialUsually a full subnet | YesOne Policy for each Resource |
| Works for protocols other than SSH | PartialWith an SSH tunnel | Yes | YesTCP, UDP, and ICMP |
| Sign-in with your identity provider | PartialNeeds more software | YesMost products | YesOIDC or an email code |
| Stays available if one host stops | NoUnless you run and patch a second host | PartialDepends on the product | YesTwo or more Gateways in a Site |
| No more software on the laptop | YesAn SSH client is enough | NoA VPN client | NoThe Firezone Client |
The table describes the usual design of each category. A specific product can be different. Read the documentation of the product before you decide.
Common questions
What is the difference between a bastion host and a jump box?
There is no practical difference. Bastion host, jump box, jump server, and jump host are names for the same thing. Each one is a hardened server that admins use as the first hop to private servers.
Is a bastion host secure?
A hardened bastion host is much safer than a public IP address on each server. It still has an open port on the internet, and one stolen key can give access to many servers. Follow the best practices in this guide, or use a design with no inbound port.
Why is SSH agent forwarding a risk on a jump server?
SSH agent forwarding makes your key agent available on the jump server. A person with root on that server can use your agent to sign in to other servers as you. Use ProxyJump, which sends the second connection through the jump server and keeps the agent on your laptop.
Do I need a bastion host if I have a VPN?
Usually not. A VPN already gives a private path to the servers. Many teams keep the two, and then they have two public entry points to patch. A design with no inbound port removes the two entry points.
What is a good bastion host alternative?
The usual alternatives are a session manager from your cloud provider, an overlay network, and zero trust network access. All of them use outbound connections from the private network, so no public SSH port stays open. Firezone is a zero trust option that also carries databases, web apps, and RDP.
Does Firezone record SSH sessions?
No. Firezone does not record the content of a session. Flow Logs show who connected to which Resource, when, and how much data moved. Use the audit tools of the server for a record of commands.