Skip to content

feat(BRE2-1051): ssh certs uptake - #452

Open
patelspratik wants to merge 1 commit into
mainfrom
feat/ssh-certs
Open

feat(BRE2-1051): ssh certs uptake#452
patelspratik wants to merge 1 commit into
mainfrom
feat/ssh-certs

Conversation

@patelspratik

@patelspratik patelspratik commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
  • Use SSH Certs instead of keys where possible. Fallback to keys.
  • Posthog Flag to control hard requiring SSH Certs for eligible envs

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.11024% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.20%. Comparing base (17ccd79) to head (a12991d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sshcert/sshcert.go 60.68% 31 Missing and 15 partials ⚠️
pkg/cmd/shell/mintcert.go 80.24% 12 Missing and 4 partials ⚠️
pkg/cmd/shell/shell.go 0.00% 13 Missing ⚠️
pkg/ssh/sshconfigurer.go 85.36% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #452      +/-   ##
==========================================
+ Coverage   24.67%   26.20%   +1.52%     
==========================================
  Files         134      137       +3     
  Lines       18337    18858     +521     
==========================================
+ Hits         4525     4942     +417     
- Misses      13335    13400      +65     
- Partials      477      516      +39     
Flag Coverage Δ
Linux 26.20% <68.11%> (+1.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@patelspratik
patelspratik force-pushed the feat/ssh-certs branch 4 times, most recently from f1c4114 to 9b4209d Compare August 24, 2026 19:21
Foundation for certificate-based SSH auth. Generates fresh ed25519
keypairs per renewal, caches the (private key, certificate) pair on
disk for the certificate's validity window, and writes atomically
(0600 private key). Files live under ~/.brev/ssh-certs/<envID>{,-cert.pub}
so a single IdentityFile directive loads both key and cert (OpenSSH
-cert.pub convention).

Independent of the IssueEnvironmentSSHCertificate RPC so the rest of
the feature can build and test before the generated connect client is
published. Includes EnvironmentCertEligible() mirroring dev-plane's
label constants (sshprovider=certauth).
@patelspratik
patelspratik marked this pull request as ready for review August 24, 2026 19:26
@patelspratik
patelspratik requested a review from a team as a code owner August 24, 2026 19:26
@patelspratik patelspratik changed the title Feat/ssh certs feat(BRE2-1051): ssh certs uptake Aug 24, 2026
})
},
}
cmd.Flags().StringVar(&env, "env", "", "environment ID to mint a certificate for")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we keep this vague (similar to ssh, which is "the name or ID") so that we could possibly support external nodes with the same command?

Comment thread pkg/ssh/sshconfigurer.go
}

func makeSSHConfigEntryV2(workspace entity.Workspace, privateKeyPath string, cloudflaredBinaryPath string) (string, error) { //nolint:funlen,gocyclo // ok
var isSSHCertRequired = analytics.IsSSHCertRequired

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this so that it can be mocked?

Comment thread pkg/ssh/sshconfigurer.go
}

sshConfig, err := makeNewSSHConfig(toWindowsPath(configPath), workspaces, toWindowsPath(pkpath), toWindowsPath(cloudflaredBinaryPath))
sshConfig, err := makeNewSSHConfig(toWindowsPath(configPath), workspaces, toWindowsPath(pkpath), toWindowsPath(cloudflaredBinaryPath), false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we pass a const or enum for this final boolean?

Comment thread pkg/sshcert/sshcert.go
return now.Add(margin).Unix() < notAfter
}

func HasValidCertAt(fs afero.Fs, certPath string, now time.Time, margin time.Duration) (bool, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we similarly check that the private key is sound / paired to the public key that this cert was issued for ?

Comment thread pkg/ssh/sshconfigurer.go
{{ end }}
`

const SSHCertRequiredTemplateV2 = `Match host {{ .Alias }} exec {{ .ExecCommand }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do the exec commands need to be quoted (and below)?

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