33 Commits
Author SHA1 Message Date
Tiago Silva cf35a5f9ba feat(beams): carry beam_id through identity certificates (#67972)
* feat(certs): thread beam_id through identity certificates

Carries the beam identifier from a delegation session's BeamIDLabel into
issued SSH/TLS certificates and back out via the cert extensions/ASN.1 OID,
exposes it on tlsca/sshca Identity and the decision PDP identities, propagates
it through scoped cert reissue (auth_with_roles), and surfaces it on event
UserMetadata for attribution.

* handle missing event cases

* prevent overriding beams_id cert extension with roles cert extensions

* handle code review comment
2026-06-23 13:36:36 +00:00
rosstimothy 4f17314a11 Initial migration to the Opaque API (#67279)
* Convert existing non-gogo codegen to the Hybrid API

Contributes to https://github.com/gravitational/teleport/issues/66776.

All existing protos explicitly set to API_OPEN have been change to
API_HBYRID. The new codegen was performed via make grpc. There are no
other functional changes to the code to start consuming the Hybrid API
those will come later. The intent is to get all Hybrid codegen in and
backported to ease the transition.

* Initial migration to the Opaque API

Contributes to https://github.com/gravitational/teleport/issues/66776.

All of the changes here are mechanical conversions generated from
`open2opaque rewrite -levels=green ./...`. There will be a follow up
to this in teleport.e which does the same. Once all changes have been
merged the process will be repeated with -levels=yellow followed by
-levels=red.


See https://protobuf.dev/reference/go/opaque-migration/ for more
details.
2026-06-05 14:52:58 +00:00
Brian JoergerandKevin 4c4d5b460e Replace flaky test TestModeratedSessionWithMFA (#66650)
* Make moderated session presence interaval configurable.

* Add moderated session test for presence checks; Remove flaky portion of TestModeratedSessionWithMFA.

* Fix mockSSHChannel.

* Remove flaky and redundant moderated sessions test.

* Apply suggestions from code review

Co-authored-by: Kevin <76608931+kshi36@users.noreply.github.com>

* Fix merge conflicts.

* Don't drain server channel in mocked ssh session.

* Add comment.

* Allow expected ErrClosedPipe in test.

---------

Co-authored-by: Kevin <76608931+kshi36@users.noreply.github.com>
2026-06-03 21:46:40 +00:00
Chris Thach c46a8f5f14 Migrate MFA service from v1 to v2 (#66820)
* Migrate from mfa v1 to v2.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Set deprecated proto option and update migration comment.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Reduce nolint directives.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Tag Ryan for the Desktop TODO.

---------

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
2026-05-22 18:49:20 +00:00
804c7f9f43 SSH client must prove key ownership before proceeding with MFA checks (#64308)
* Perform full SSH RBAC checks in VerifiedPublicKeyCallback and only check cert/key in PublicKeyCallback.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Cert checker performs a light check in PublicKeyCallback.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Make lint happy.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Keep core auth checks in pubkey and auth steering in verifiedpubkey.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix missing error when !ok.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use DiscardUnknown when unmarshaling.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return nil if ssh permit not set.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix grammar.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Simplify and clarify.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix nil panic.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Apply suggestion from @rosstimothy

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Remove unnecessary helper.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Simplify changes to git server.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add TestVerifiedPublicKeyCallback.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix auth loop on legacy public key flow.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use perms.ExtraData with an override func.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Set client version for SSH clients. Allow per-session MFA for legacy clients and in-band MFA for modern clients.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add more tests.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove client version in proxy-node to preserve legacy path.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow modern clients to use per-session MFA certs temporarily.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Refactor and fix paths.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert change to proxy client.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix client test.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Set client version in forward server.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Set SSHClientVersion to SSH-2.0-Teleport_v1.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Set Teleport version in SSH clients.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add more tests. Fix lint.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix import. Fix lint exclude.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint - come on!

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix race by making a defensive copy.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use ErrorIs.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Deep clone client conf. Early return for err. Make consistent.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return new conf if nil. Add trace.Wrap to missing.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add IsSSHFeatureSupported. Switch from api to api_test for test pack. Make prefix exported const.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert accidental commit.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return sentinel error for older clients or non-teleport clients to improve downstream handling.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert changes and use base branch version.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Clean up.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Clean up.

Co-authored-by: Chris Thach <chris.thach@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@gmail.com>

* Remove defensive check.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Change from trace.BadParam to reg error.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use strings.Cut and improve readability.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use error struct.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add test that errors if ssh.ClientConfig changes.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Move to subpackage.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use static assertion instead.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return error if config is nil.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow clients to override client version via config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix test because I forgot to update it.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Move assert to test file.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove error return val.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Relax parser to allow for more.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* WIP take on a tracessh wrapper. Will fail CI.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add tests and polish new package.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert changes to tracessh. Add lint config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert changes to use tracessh.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Delete extra s.

Co-authored-by: Chris Thach <chris.thach@protonmail.com>

* Apply suggestions from code review.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add IsEmpty helper methods.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* First pass of refactoring.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Second pass refactor.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Refactor SSH feature support checks to use new apissh methods.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix logging for cert.Perms by only logging printable.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Make error msg more user friendly.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Third pass refactor.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix nil panic.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix missing user value.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix missing User value.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove Get from name. Polish.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix incorrect signers for clients. Make changes consistent.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow ClientConfig to be empty in proxy config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix eager signers regression in generateClientConfig.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use new exported helper.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add edge case for space after prefix.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Update outdated comment ref. Delete dead code.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix issues from code review.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Drop suffix. Update comments.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Update ClientConfig docs.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add warning about using the Teleport version.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Teleport version is mandatory.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert timeout to make Claude/Codex happy.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Apply suggestions from code review

Co-authored-by: Brian Joerger <bjoerger@goteleport.com>

* Update tests. Refactor switch based on Brian's suggestion.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove alias in places that didn't need it. Revert lib/cloud/gcp/alloydb.go.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add wrapper for tracessh.Client.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add tests for generate client config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Drop config from field name to shorten.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint issues.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Refactor to allow skipping in-band if hardware key was used.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix test I forgot to update.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow hardware key client even if force in-band is active.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove extra line.

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

---------

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@gmail.com>
Co-authored-by: Brian Joerger <bjoerger@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2026-04-09 15:44:43 +00:00
Edoardo Spadolini 825b23049e session-helper: move srv.RunAndExit to session/reexec (#65263)
* Move the reexec parts of lib/srv to session/reexec

* Update references to the moved bits of lib/srv

* Avoid testutils in session/reexec

* Shuffle some constants around to avoid imports in session/reexec

* Vendor in the relevant parts of logutils in session/reexec

* Remove unnecessary symlink checks when opening files

* Inline the last two things from lib/utils in session/reexec

* Inline moved constants

* Deprecate group name consts and fix missed inlines

* Add missing session/reexec.TestMain with reexec check

* Reuse existing constants from the log constants package in session

* Fix broken godoc link
2026-04-08 09:40:52 +00:00
306b6a9db0 Set Teleport version in SSH clients (#65004)
* Set Teleport version in SSH clients.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add more tests. Fix lint.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix import. Fix lint exclude.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint - come on!

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix race by making a defensive copy.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use ErrorIs.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Deep clone client conf. Early return for err. Make consistent.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return new conf if nil. Add trace.Wrap to missing.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add IsSSHFeatureSupported. Switch from api to api_test for test pack. Make prefix exported const.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert accidental commit.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return sentinel error for older clients or non-teleport clients to improve downstream handling.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Clean up.

Co-authored-by: Chris Thach <chris.thach@protonmail.com>

* Apply suggestions from code review

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@gmail.com>

* Remove defensive check.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Change from trace.BadParam to reg error.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use strings.Cut and improve readability.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use error struct.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add test that errors if ssh.ClientConfig changes.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Move to subpackage.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Use static assertion instead.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Return error if config is nil.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow clients to override client version via config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix test because I forgot to update it.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Move assert to test file.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove error return val.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Relax parser to allow for more.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* WIP take on a tracessh wrapper. Will fail CI.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add tests and polish new package.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert changes to tracessh. Add lint config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert changes to use tracessh.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Delete extra s.

Co-authored-by: Chris Thach <chris.thach@protonmail.com>

* Apply suggestions from code review.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add IsEmpty helper methods.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* First pass of refactoring.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Second pass refactor.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Third pass refactor.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix nil panic.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix missing user value.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix missing User value.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove Get from name. Polish.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix incorrect signers for clients. Make changes consistent.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Allow ClientConfig to be empty in proxy config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix eager signers regression in generateClientConfig.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add edge case for space after prefix.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix issues from code review.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Drop suffix. Update comments.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Update ClientConfig docs.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add warning about using the Teleport version.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Teleport version is mandatory.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Revert timeout to make Claude/Codex happy.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Remove alias in places that didn't need it. Revert lib/cloud/gcp/alloydb.go.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add wrapper for tracessh.Client.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Add tests for generate client config.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Drop config from field name to shorten.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix lint issues.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

---------

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@gmail.com>
2026-04-07 18:06:00 +00:00
Edoardo Spadolini 644f415a27 session-helper: submodule preparation and dependencies of lib/srv/reexec.go (#65145)
* Depguard rules for the session submodule

* Move lib/auditd to session/auditd

* Move lib/loginuid to session/loginuid

* Reduce dependencies of lib/utils/envutils

* Move lib/utils/envutils to session/envutils

* Split the SSH utilities of sshutils/x11 into sshutils/x11forward

* Move lib/sshutils/x11 to session/networking/x11

* Move lib/sshutils/networking to session/networking

* Move lib/shell to session/shell

* Move lib/utils/uds to session/uds

* Move lib/utils/host to session/host

* Move lib/pam to session/pam

* Avoid lib/utils/log in session/pam

* Move lib/service/servicecfg.PAMConfig to session/pam/pamcfg.PAMConfig

* Move lib/srv/uacc to session/uacc

* Avoid importing lib/utils in session/uacc

* Move lib/selinux to session/selinux

* Avoid lib/utils and lib/utils/log in session/selinux

* make go-mod-tidy-all

* Update oss-fuzz path for session/networking/x11
2026-04-01 12:34:10 +00:00
Andrew LeFevreandAndrew LeFevre 2078c88da9 Fix logs from reexecuted processes not being logged in tests (#64038)
* ensure logs for reexec processes are shown when running unit tests

* log audit session login IDs as strings

---------

Co-authored-by: Andrew LeFevre <andrewlefevre@goteleport.com>
2026-03-25 09:31:26 +00:00
Chris Thach f4387cef97 Add SSH keyboard-interactive auth after public key auth for in-band MFA (#63067)
* Add support for in-band MFA flow to Agent SSH server.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Refactor to improve clarity. Fix missing MFA client.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Deny legacy pub key callback auth with error.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix typo. Add TODO.

* Abstract MFA gRPC client with interface.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Replace with a switch to set us up for the future.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix docs.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

* Fix error string.

* Fix assertion.

---------

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
2026-01-26 13:55:43 +00:00
rosstimothy 6590c944b6 Inject modules into keygen (#62843)
Contributes to #62799.
2026-01-16 18:52:50 +00:00
Zac Bergquist 35ef392bc4 docs: update FIPS info (#61973)
This consolidates all references to BoringCrypto and FIPS-140-2 to
a single section of the docs, using more generic FIPS terminology
elsewhere. As a result, we only need to change one place when we
update our FIPS module in the future.

In addition, mention the specific versions of BoringCrypto and
associated CMVP certificate numbers.
2025-12-15 18:29:48 +00:00
Andrew LeFevreandjoerger 6fb284b786 expose logs of Teleport child processes (#61297)
* expose logs of Teleport child processes

Configures Teleport child proceses to log with the exact same
configuration as the parent process. Logs from child processes
previously were essentially discarded.

* Fix issues around os_log; Fix log spam from child process.

* Address comments; Fix lint.

* * Only write remote command failure errors to client tty

* Don't try to write errors to unserviced os.Stderr/Stdout of child process

* Don't connect networking stderr to parent process, just use logger

* Don't log client-responsible shell errors, e.g. shell interrupt

* Mention running teleport as root for common subprocess permission errors.

* Pass io.Discard pipe to child process if a log writer is not available.

* Fix tests with nil log writer.

* Add default child logger for tests.

* Fix lint.

* default to discard writer for tests.

* Write reexec errors to os.Stdout for parent process to digest.

* Address comments.

* Clean up child pipe copy logic.

* Cleanup log config inheritance.

* Address comments.

* Revert whitespace change.

* Fix typo.

* Fix merge conflict.

---------

Co-authored-by: joerger <bjoerger@goteleport.com>
2025-12-09 20:27:31 +00:00
Brian Joerger a3e24fecd6 Extend timeout for child process continue signal (#61570)
* Extend timeout and respect context for child process continue signal.

* Address comments.

* Only wait for child signal when BPF and PAM are enabled.

* Clean up WaitForChild logic; Fix issue caused by forwarding server returning error from GetPAM method.

* Address comments.

* Fix aggregating wait and close error.

* Remove _ for ctx parameter.
2025-12-08 20:09:47 +00:00
Tiago SilvaandEdoardo Spadolini 2ae3a21a51 fix: prevent crypto/ssh to block on dialing (#59967)
* fix: prevent `crypto/ssh` to block on dialing

`crypto/ssh` dialing doesn't support timeouts or context cancellation
propagation by default. Although `ssh.ClientConfig` has a field
`Timeout`, this field is only used when establishing a new TCP
connection but it's never used for ssh handshake.

This means that if the target server never replies and no intermediary
closes the connection, the connecton will be kept alive forever causing
Teleport dialer to deadlock and never recover.

Although teleport `ssh` package has `NewClientConnWithDeadline`, not all
every Teleport implementation of `net.Conn` supports read deadlines,
which means we can have cases where the system also deadlocks when using
`NewClientConnWithDeadline` and a timeout.

This PR tries to solve it by closing the underlying connection when the
minimum time between the context's deadline, the timeout and if none set
30s.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* Apply suggestion from @espadolini

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* fix code

* rename methods to correctly describe the behavior

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle code review comment

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2025-10-10 14:00:39 +00:00
Brian Joergerandrosstimothy 4774000ce2 Make SSH session client provide session params upfront rather than with synchronous envs@goteleport.com requests (#59206)
* Client: add session channel request extra data to replace env vars.

* Server Changes:

- Set session params on server side from request, with env var fallback for backwards compatibility.

- Remove CreateOrJoinSession.

- Separate JoinSession from OpenSession; Remove session ID from connection context as it is now purely controlled by the session.

- Ensure participant mode is always set for joining.

* Replace NewSessionWithParams method.

* Update comments.

* Move session params to server context.

* Add ModeratedSessionID to session params to replace TELEPORT_MODERATED_SESSION_ID env var.

* Fix nil reference.

* Fix tests.

* Only send session params to Teleport servers.

* Add WebProxyAddr to session params.

* Cleanup.

* Add tests.

* Fix test.

* Address comments.

* Add NewSessionWithParams.

* Fix tests.

* Update comment.

* Update api/observability/tracing/ssh/client.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix forwarding server missing Teleport ssh version.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2025-10-03 23:44:16 +00:00
64f6154301 Fix discrepancies between Node and Proxy recording modes. (#58707)
* Fix usage of node server ID and proxy host UUID in the forwarding server.

* Make GetInfo and TargetMetadata consistent between the forwarding and regular server.

* Rename TargetMetadata to EventMetadata and only use it for events' ServerMetadata.

* Remove unused method.

* Resolves comments on test.

* Remove unused fields.

* Update lib/srv/ctx.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Update integration/integration_test.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2025-09-23 23:45:20 +00:00
Brian JoergerandSTeve Huang 72855b6095 Fix session ID env var handling for joining sessions (#59294)
* Refactor server session ID logic; Separate join and open session flows.

* Remove unused client node session ID.

* Fix backwards compatibility.

* Fix tests and lint.

* Update deprecation TODO.

* Fix failing test caused by delayed association with join session.

* fix session ID for git events

---------

Co-authored-by: STeve (Xin) Huang <huangin52@gmail.com>
2025-09-23 00:37:22 +00:00
Tiago Silva 64ae08da62 Refactor test assertions to use consistent variable naming in require.EventuallyWithT calls (#58997)
* Refactor test assertions to use consistent variable naming in `require.EventuallyWithT` calls

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle code review comment

* handle code review comment

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-09-15 15:19:53 +00:00
Andrew Burke 8b0b3966d9 Add wtmpdb support (#58187)
This change adds support for wtmpdb as a uacc backend.
2025-09-04 00:33:51 +00:00
rosstimothy 7541d6d7d0 Introduce logtest package (#56741)
Moves all test related logger initialization and creation to the
logtest package to reduce testing symbols in production code. The
existing helpers in lib/utils have been left in place until the
enterprise references can be converted.

Updates #51023.
2025-07-15 18:11:10 +00:00
Zac Bergquist 07e2fec1b2 Apply more modernize fixes (#55975)
- lib/srv
- lib/limiter
- lib/multiplexer
- lib/usagereporter
2025-06-22 10:54:09 +00:00
Andrew LeFevre 6bf6aa60e6 add SELinux module for SSH service (#53424) 2025-05-13 20:54:51 +00:00
Forrest 33b2bb4ee0 refactor lib/srv to adopt pdp-style patterns (#54081) 2025-05-06 16:37:03 +00:00
Noah StrideandMarco Dinis 0586278cde Migrate GetClusterName to gRPC (#53164)
* Adjust GetClusterName method signature to include context.Context

* Start hacking on gRPC GetClusterName impl

* Fix test mocks to match signature

* Fix integration tests

* Fix integrations tests

* Missing ctx

* New GetClusterName RPC implementatin

* Add fallback cluster name

* Correct godoc comment

* Remove unused method

* Remove unused import

* Fix E2E test

* Fix tests

* Fix deferred context cancel in test conflicting with parallel subtests

* Fix import

* Fix imports

* Update lib/auth/auth_with_roles.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2025-03-20 10:07:02 +00:00
STeve (Xin) Huang 4696be3655 GitHub proxy: emit rbac failure event and add prometheus counters (#51878)
* GitHub proxy: emit rbac failure event and add prometheus counters

* move device metadata to sshca.identity
2025-02-21 16:15:44 +00:00
Forrest b9232c3013 transition ssh enforcement to sshca.Identity (#51468) 2025-02-04 18:01:53 +00:00
Forrest 5791a9888a Add host fields and protos for ssh identities (#51024)
* add host fields to sshca.Identity

* add ssh identity proto
2025-01-27 18:51:37 +00:00
STeve (Xin) Huang ef96070925 GitHub proxy: download GitHub server keys (#50891)
* GitHub proxy: download GitHub server keys

* review comments
2025-01-21 14:59:10 +00:00
STeve (Xin) Huang db4527521e Fix flaky git.TestForwardServer test (#51112) 2025-01-16 15:01:15 +00:00
STeve (Xin) Huang b1b6548611 GitHub Proxy: complete audit event flow and add an enterprise guard (#51049) 2025-01-15 15:47:41 +00:00
STeve (Xin) Huang f0abbce0fd GitHub proxy part 6: proxing Git using SSH transport (#49980)
* GitHub proxy part 6: proxing Git using SSH transport

* better command parsing and update suite

* refactor

* revert unnecearrty files

* address review comments

* ut fix

* revert localsite_test.go

* change special suffix to teleport-github-org for routing

* fix routing ut

* minor typo edit

* fix ut after sshca change

* add UT to sshutils

* minor review comments

* fix api ut because of special suffix change

* GitServerReadOnlyClient

* downgrade error to warning

* run go mod tidy. not sure why it's needed

* rename mock.go to mock_test.go
2025-01-14 21:48:04 +00:00
STeve (Xin) Huang 95c1697f7c GitHub proxy: git command recorder (#50505)
* GitHub proxy: recording git command

* address review

* review comments

* allow flags after repository for git-upload-pack
2025-01-14 17:54:52 +00:00