Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce time spent setting ssh session envs #23731

Merged
merged 5 commits into from
Mar 30, 2023
Merged

Reduce time spent setting ssh session envs #23731

merged 5 commits into from
Mar 30, 2023

Conversation

rosstimothy
Copy link
Contributor

@rosstimothy rosstimothy commented Mar 28, 2023

tsh sets a number of environment variables when setting up the users session. Each key value pair is transmitted one at a time in a "env" ssh request, which adds a number of envs * RTT of additional latency per session.

This introduces a new envs@goteleport.com request which sets multiple environment variables in a single ssh request, which reduces the amount of time spent setting envs down to the RTT of a single ssh request. In order to ensure backward compat and interoperability with OpenSSH, if the server does not recognize the envs@goteleport.com request the ssh client will resort to sending individual "env" requests.

@rosstimothy rosstimothy force-pushed the tross/ssh_envs branch 2 times, most recently from 592b152 to c76c825 Compare March 28, 2023 21:56
@rosstimothy
Copy link
Contributor Author

traces captured from a customer
image

tsh v12.1.0
Screenshot 2023-03-29 at 9 55 13 AM

tsh from this branch
Screenshot 2023-03-29 at 9 55 47 AM

@rosstimothy rosstimothy marked this pull request as ready for review March 29, 2023 14:08
`tsh` sets a number of environment variables when setting up the
users session. Each key value pair is transmitted one at a time
in a "env" ssh request, which adds a num envs * RTT of additional
latency per session.

This introduces a new `envs@goteleport.com` request which sets
multiple environment variables in a single ssh request, which
reduces the amount of time spent setting envs down to the RTT of
a single ssh request. In order to ensure backward compat and
interoperability with OpenSSH, if the server does not recognize
the `envs@goteleport.com` request the ssh client will resort to
sending individual "env" requests.
Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

Nice optimization!

api/observability/tracing/ssh/session.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/session.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/ssh.go Show resolved Hide resolved
api/observability/tracing/ssh/ssh.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/ssh.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Show resolved Hide resolved
lib/srv/forward/sshserver.go Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Outdated Show resolved Hide resolved
api/observability/tracing/ssh/client_test.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Show resolved Hide resolved
rosstimothy and others added 2 commits March 29, 2023 17:46
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Copy link
Contributor

@marcoandredinis marcoandredinis left a comment

Choose a reason for hiding this comment

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

LGMT

Just a question: does this optimization work for direct connections and for webui/connect ssh sessions?

@rosstimothy
Copy link
Contributor Author

LGMT

Just a question: does this optimization work for direct connections and for webui/connect ssh sessions?

Connect calls tsh ssh directly and the Web UI uses the client.TeleportClient to create a session, so they will benefit as long as the Teleport ssh_service understands the new envs@goteleport.com. Any older Teleport instances or OpenSSH instances will still use the standard env request to send variables one at a time.

@rosstimothy rosstimothy added this pull request to the merge queue Mar 30, 2023
Merged via the queue into master with commit 65106a1 Mar 30, 2023
20 checks passed
@rosstimothy rosstimothy deleted the tross/ssh_envs branch March 30, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants