What is a bastion host?
A bastion host is a server whose only job is to be the controlled entry point into a private network. NIST's glossary defines it as a special-purpose computer built and configured to withstand attacks. In day-to-day hosting the same machine is often called a jump server, jump host or jump box: you jump through it to reach the servers behind it.
The layout is simple. Your database, application and cache servers have SSH reachable only on a private network. One small server, the bastion, has SSH reachable from the internet. To manage anything, you SSH into the bastion first and from there into the target. Nothing else on the network accepts a login from outside.
A bastion is not a firewall and not a VPN, although it is often used alongside both. It is an ordinary Linux server with almost everything removed, so that the one service it does run, SSH, is easy to audit and hard to attack.
Why use a bastion host?
- One door to guard instead of ten. Every server with port 22 open to the internet gets constant password-guessing and scanning. With a bastion, only one machine faces that traffic, and you can harden, patch and watch it closely.
- One place to log and audit. Every administrative session passes through the bastion, so its logs show who connected, when, from which IP address and with which key.
- Simpler firewall rules. Internal servers need one rule: accept SSH only from the bastion's private IP. Adding a new team member or a new office IP changes the bastion only.
- Faster offboarding. When someone leaves, removing their key from the bastion cuts off access to everything behind it, even if a stray key remains on an internal server.
- Smaller attack surface for data servers. A database server with no public SSH and no public database port has very little for an outsider to probe.
The trade-off is that the bastion becomes a single point of failure for admin access, and a valuable target. Both are manageable: keep a second way in (a provider console or a second bastion), and treat the bastion as the most locked-down machine you own.
How SSH through a bastion works: ProxyJump
The old way was to SSH into the bastion, then run ssh again from there. That needs your private key, or a forwarded agent, on the bastion, which is exactly what you want to avoid. OpenSSH 7.3, released in August 2016, added a cleaner method: the ProxyJump option and its -J flag.
With ProxyJump, your laptop opens an SSH connection to the bastion and asks it to forward a TCP connection to the internal server. Your laptop then runs a second, end-to-end encrypted SSH session to the internal server through that tunnel. The bastion only passes bytes along. It never sees your private key, and it cannot read the inner session.
One command does the whole hop:
ssh -J deploy@bastion.example.in deploy@10.10.0.12
Here bastion.example.in is the bastion's public name and 10.10.0.12 is the internal server's private IP address. You can chain several hops with commas, for example -J user@hop1,user@hop2, and a non-standard port with user@host:2222.
The same works for file copies, because scp and sftp accept -J too. Our guide to SFTP and SCP covers the rest of their options.
scp -J deploy@bastion.example.in backup.sql deploy@10.10.0.12:/home/deploy/
Setting up ~/.ssh/config for a jump host
Typing -J every time gets old quickly. Put the bastion and your internal servers in ~/.ssh/config on your laptop instead:
# The bastion: the only host reachable from the internet
Host bastion
HostName bastion.example.in
User deploy
IdentityFile ~/.ssh/id_ed25519
ForwardAgent no
# Internal servers: reached through the bastion over the private network
Host app1
HostName 10.10.0.11
User deploy
ProxyJump bastion
Host db1
HostName 10.10.0.12
User deploy
ProxyJump bastion
# Or cover a whole private range at once
Host 10.10.0.*
User deploy
ProxyJump bastion
Now ssh db1 goes through the bastion automatically, and so do scp, rsync over SSH, Git and editors that use your SSH config. The ssh manual notes that options given on the command line usually apply to the destination, not the jump host, so settings for the bastion itself belong in this file.
The same config also handles SSH tunnels through the bastion. To open a private database port on your laptop:
ssh -L 5432:10.10.0.12:5432 bastion
Your local database tool then connects to localhost:5432, and the database server never needs a public port.
Agent forwarding: why ProxyJump is safer
Many older tutorials tell you to use ssh -A (agent forwarding) so that the bastion can use your keys to log in onward. The OpenSSH manual warns that this should be enabled with caution. Anyone who can bypass file permissions on the remote host, which means root on the bastion or an attacker who has become root, can use your forwarded agent socket. They cannot copy the key, but while you are connected they can authenticate as you to any server that trusts it.
A bastion is the one machine most likely to be attacked, so it is the worst place to expose your agent. Practical rules:
- Use
ProxyJumprather than-A. It needs no agent on the bastion at all. - Set
ForwardAgent nofor the bastion in~/.ssh/config, which is also the default. - If you must forward an agent somewhere, add keys with
ssh-add -cso each use asks you for confirmation. - Never store private keys on the bastion itself.
Hardening the bastion
Start from a minimal Linux install and follow the usual initial server setup, then go further. A sensible /etc/ssh/sshd_config for a bastion looks like this:
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
AllowUsers deploy alice
AllowAgentForwarding no
X11Forwarding no
PermitTunnel no
AllowTcpForwarding yes
LogLevel VERBOSE
Keep AllowTcpForwarding on, because ProxyJump depends on it, but switch off agent, X11 and tunnel-device forwarding. If you want to restrict where users can jump to, PermitOpen limits forwarding to listed destinations, for example PermitOpen 10.10.0.11:22 10.10.0.12:22 (list every destination users need, including any database port you tunnel to, such as 10.10.0.12:5432). For users who should only ever jump, never get a shell, a Match User block with ForceCommand /sbin/nologin still lets -J work while refusing interactive logins.
Other basics: install nothing else on the bastion (no web server, no database, no build tools), apply security updates promptly, and restrict who can reach port 22 on it. If your team works from fixed office IPs, allow only those in the firewall.
Keys and multi-factor authentication
Use SSH keys, not passwords. Ed25519 keys are short and fast; our guide to SSH keys shows how to create and install them. Give every person their own key so the logs can tell them apart, and never share one key across a team. NIST IR 7966 covers SSH key management in organisations, including the risk of keys that nobody tracks or removes.
For a second factor, sshd can require more than one method with AuthenticationMethods. Two common options:
- Hardware-backed keys. OpenSSH supports FIDO2 security keys through the
ed25519-skkey type, so the private key cannot be used without the physical token. - Key plus one-time code.
AuthenticationMethods publickey,keyboard-interactiveasks for a key and then a code from a PAM module such as a TOTP authenticator. This needsKbdInteractiveAuthentication yesand a configured PAM module, so test it carefully before you rely on it.
Logging
With LogLevel VERBOSE, sshd records the fingerprint of the key used for each login, which tells you which person connected, not only which account. Avoid DEBUG levels in production; the manual notes they violate users' privacy. Send the bastion's logs to another machine as well, because an attacker who gets in will try to clean the local copy. If you need full session recording for compliance, look at dedicated tools for that rather than shell history, which users can edit.
Locking SSH on internal servers to the bastion
A bastion only helps if the internal servers refuse SSH from everywhere else. On each internal server, allow port 22 from the bastion's private IP and nothing more. With ufw:
sudo ufw allow from 10.10.0.5 to any port 22 proto tcp
sudo ufw delete allow OpenSSH
sudo ufw status numbered
sudo ufw enable
The delete line matters if you followed our initial setup guide, which adds ufw allow OpenSSH: that earlier rule allows SSH from anywhere and ufw stops at the first matching rule, so a later deny would never be reached. Check ufw status numbered and remove any other rule that allows port 22 from anywhere; ufw already denies other incoming traffic by default.
Here 10.10.0.5 is the bastion's private address. You can go further and bind sshd to the private interface only with ListenAddress 10.10.0.12 in sshd_config, so it does not even listen on the public IP. Do the same in any provider-level firewall, so the rule holds even if the host firewall is reset.
Check from outside that it worked: from your laptop, ssh deploy@<public-ip-of-db1> should now time out, while ssh db1 through the bastion still works. If it does not, our SSH connection refused guide covers the usual causes.
Running a bastion on Bigdomainhost servers
A bastion needs very little: one vCPU-class workload, a small disk, and a fast private link to the servers it guards. On a Bigdomainhost KVM VPS, every server gets one public IPv4 address and a private interface within its region, and private traffic between your own servers in the same region is free and stays on the internal network. The networking docs also note that the default firewall policy denies inbound traffic except SSH on port 22, and you can edit firewall rules per server from the control panel.
The private network is per region, so put the bastion in the same region as the servers it serves: Mumbai (BOM-1) or Delhi NCR (DEL-1), both in Tier III facilities, as listed on our locations page. If you run servers in both regions, use one bastion in each. The smallest plan is usually enough for a bastion; servers are prepaid in 30-day periods from a rupee wallet.
Bastion host vs VPN vs session-manager tools
A bastion is not the only way to keep SSH off the public internet. The main options compare like this:
| SSH bastion | VPN (WireGuard, OpenVPN) | Cloud session manager / identity-aware proxy | |
|---|---|---|---|
| What you open to the internet | SSH on one server | One UDP or TCP port on the VPN server | No public inbound port; an agent connects out (AWS), or only Google's IAP range may connect in (Google Cloud) |
| What users reach | SSH and SSH tunnels | The whole private network, any protocol | Shell sessions and forwarded ports, per policy |
| Software needed | OpenSSH, already installed | VPN client on every laptop | The provider's agent and CLI |
| Audit trail | sshd logs on the bastion | VPN connection logs; per-host logs for the rest | Central session logs, often with recording |
| Works across providers | Yes | Yes | Usually tied to one cloud |
| Best for | Small teams, Linux servers, SSH-only admin | Teams that need databases, dashboards and SSH together | Large fleets already inside one cloud |
WireGuard describes itself as a simple, fast, modern VPN. A common pattern is to run WireGuard on the bastion itself, so SSH is not exposed at all and staff connect to the VPN first. AWS Systems Manager Session Manager and Google Cloud IAP TCP forwarding keep SSH off the public internet by having an agent (AWS) or Google's proxy (IAP) broker the connection. AWS presents Session Manager as removing the need for open inbound ports and bastion hosts, and Google's IAP lets you reach VMs that have no external IP address. They work well inside those clouds but do not cover servers elsewhere.
For a handful of Linux servers, a well-hardened bastion with ProxyJump is often the simplest option that gives you a real audit trail, and it uses nothing beyond OpenSSH. If you would rather someone else handled this kind of hardening, compare managed and unmanaged VPS options first.
Questions about private networking between your servers? Message us on WhatsApp at +91 75994 50220 at any time, call during IST working hours, or email support@bigdomainhost.com.
Bigdomainhost wrote this guide with AI assistance and sells the VPS servers it describes. OpenSSH options were checked against the OpenBSD manual pages on 27 November 2026; defaults can change between OpenSSH versions, so check man ssh_config and man sshd_config on your own system.
Sources (checked )
- NIST CSRC: Glossary: bastion host
- OpenBSD manual pages: ssh_config(5): ProxyJump and ForwardAgent
- OpenBSD manual pages: ssh(1): the -J and -A options
- OpenBSD manual pages: sshd_config(5): AllowTcpForwarding, PermitOpen, AuthenticationMethods, LogLevel
- OpenBSD manual pages: ssh-add(1): confirming key use with -c
- OpenSSH: OpenSSH 7.3 release notes (ProxyJump and -J added)
- NIST: NIST IR 7966: Security of Interactive and Automated Access Management Using Secure Shell (SSH)
- WireGuard: WireGuard: fast, modern, secure VPN tunnel
- AWS Documentation: AWS Systems Manager Session Manager
- Google Cloud: Using IAP for TCP forwarding