How to Configure Ubuntu Relay Host

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an ubuntu relay host by routing SSH traffic through an intermediate server. This single machine sits between external users and your private network. Engineering teams often use this setup to keep internal servers off the public internet. Still, broad SSH roles on the relay or target hosts create serious security risks. Once a user logs in, native SSH rules cannot inspect or restrict individual commands. How an ubuntu relay host works in practice An ubuntu relay host acts as a sing

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up an ubuntu relay host by routing SSH traffic through an intermediate server. This single machine sits between external users and your private network. Engineering teams often use this setup to keep internal servers off the public internet. Still, broad SSH roles on the relay or target hosts create serious security risks. Once a user logs in, native SSH rules cannot inspect or restrict individual commands.

How an ubuntu relay host works in practice

An ubuntu relay host acts as a single entry point for remote administration. In SSH architectures, teams also call this server a relay host or relay host. Admins place this machine in a public subnet with strict firewall rules. Internal servers stay in private subnets and accept SSH traffic only from the relay.

To use this workflow, an engineer first proves their identity to the relay server. Modern setups rely on SSH key pairs or central user directories for this step. The client machine opens an encrypted SSH tunnel to the public Ubuntu server. Next, the client forwards that connection through the relay to the private target host.

Good setups disable direct shell login on the relay server itself. Users cannot run commands on the relay or store secret keys on its disk. Instead, the Ubuntu server only forwards raw network packets to the final destination. The target server then checks the user key before opening a command shell.

What native SSH forwarding solves and what it misses

A standard Ubuntu relay host reduces your public attack surface right away. You only expose one hardened SSH port to the outside world. Network teams can watch traffic at a single choke point. Patching one public server is much easier than guarding dozens of exposed machines.

Still, this network pattern leaves a major operational gap open. Native SSH forwarding only decides who can open a tunnel to a host. Once the target session starts, the relay stays blind to what happens inside. It sees encrypted packets rather than the actual commands a user runs.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Because of this limit, users often hold static roles that are too broad. An engineer who needs to check one log file gets full shell access. They might run a destructive command or read sensitive files by mistake. Standard system logs rarely capture full terminal output or mask private data like emails.

Best practices for hardening your relay setup

If you manage an Ubuntu relay host, start by removing local password logins. Require strong SSH keys or short-lived certificates for every single user session. Lock down the system SSH settings so the relay only allows port forwarding. This stops attackers from using the relay as a staging ground for tools.

Next, restrict which private subnets each user group can reach through the relay. Network firewall rules on the Ubuntu host can limit routes by user ID. Even with these host rules in place, network controls cannot govern shell commands. Closing that gap requires controls that operate at the command and data level.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should I store private SSH keys on the ubuntu relay host?

No, you should never store private SSH keys on the relay server. Keep private keys on client devices and forward the login request through the tunnel. If someone compromises the relay, stored keys would give them access to every server.

How is an SSH relay different from a VPN?

A VPN connects a user device to an entire private network subnet. An SSH relay only forwards specific terminal sessions to individual target servers. This narrower scope makes a relay easier to lock down than a full VPN.

Can native Ubuntu logs show every command run on target hosts?

No, the relay host only sees encrypted network traffic passing through the tunnel. To see actual commands, you must collect audit logs from every target server. Even then, local users with root rights can often alter those log files.

The query runs. The emails stay hidden.