Skip to content

feat(register): add brev-managed sshd on port 2222#305

Open
theFong wants to merge 7 commits intomainfrom
feat/managed-sshd-port-2222
Open

feat(register): add brev-managed sshd on port 2222#305
theFong wants to merge 7 commits intomainfrom
feat/managed-sshd-port-2222

Conversation

@theFong
Copy link
Member

@theFong theFong commented Mar 4, 2026

Summary

  • Adds a hardened, brev-managed sshd instance on port 2222 that runs alongside the system sshd
  • Public key auth only, modern ciphers/KEX/MACs, isolated ed25519 host keys in /etc/brev-sshd/, systemd unit for process supervision
  • Wired into registration (Step 2, after netbird) and deregistration (non-fatal cleanup after SSH key removal)

Test plan

  • go build ./... compiles cleanly
  • go test ./pkg/cmd/register/... ./pkg/cmd/deregister/... all pass
  • Manual test on Linux VM: brev register creates /etc/brev-sshd/sshd_config, starts brev-sshd.service, ss -tlnp | grep 2222 shows listening
  • ssh -p 2222 user@localhost works with key auth, password auth rejected
  • brev deregister stops service and removes all brev-sshd artifacts

Add a hardened sshd instance managed by brev register/deregister that
runs on port 2222 alongside the system sshd. Uses public key auth only,
modern ciphers/KEX/MACs, isolated host keys in /etc/brev-sshd/, and a
systemd unit for process supervision.

- Add ManagedSSHDaemon interface + BrevSSHD provider
- Wire sshd install as Step 2 in registration flow
- Add non-fatal sshd cleanup to deregistration flow
- Add config/unit content tests and mock-based integration tests
@theFong theFong requested a review from a team as a code owner March 4, 2026 01:12
theFong added 6 commits March 4, 2026 14:47
- Wire AddAllowedUser/RemoveAllowedUser into GrantSSHAccessToNode with
  rollback on RPC failure
- Add ReloadBrevSSHD to pick up config changes without dropping connections
- Add brev-sshd to enablessh checkSSHDaemon service list
- Split systemctl commands for better error messages and pipe stderr
- Remove unused brevSSHDBinary const
- Add tests for AllowUsers add/remove/idempotent/cleanup
…e-ssh

The managed sshd on port 2222 is only needed when SSH access is granted,
not at registration time. This moves the install step into enable-ssh so
it runs right before granting access.
When brev-sshd is not yet running, tell the user what will be installed
before proceeding. Skip the message on subsequent enable-ssh calls.
Tell the user what enabling SSH will do before they accept the prompt.
Install the managed sshd before granting access so AllowUsers and the
config exist when GrantSSHAccessToNode runs.
LoginGraceTime 30

# Reuse the same authorized_keys managed by sshkeys.go — no separate key store needed.
AuthorizedKeysFile %h/.ssh/authorized_keys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are sandboxing an entire ssh, we should use our own authorized_keys file in /etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants