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

Auto-login during SSH causes all subsequent SSH sessions to re-use the same port-forward config #17589

Closed
craigfe opened this issue Oct 19, 2022 · 5 comments
Labels
bug c-af Internal Customer Reference c-dx Internal Customer Reference server-access

Comments

@craigfe
Copy link

craigfe commented Oct 19, 2022

Expected behaviour

I can use multiple Teleport SSH sessions concurrently in the same cluster (with per-session portforwarding configuration applied).

Current behaviour

If I login to Teleport while attempting to tsh ssh with a port-forward (-L), the port-forwarding configuration is saved to my profile and subsequent concurrent SSH sessions will fail (as they contest with each other for establishing the port-forward). This happens even when none of the subsequent tsh ssh sessions specify a port-forward (since they all default to the ones set in the profile).

Bug details

If I run tsh ssh -L ... to set up an SSH session while not already logged into Teleport, the client will attempt to login automatically before performing the SSH session (the RetryWithRelogin code path). When it does this, it saves a profile in order to cache the credentials for other sessions, but this profile also contains the session-specific port-forwarding details.

Any subsequent calls to tsh ssh implicitly pick up this port-forwarding configuration, meaning it's no longer possible to have multiple sessions without them contesting for the same port as was used originally.

This seems to have been introduced in #581 in order to support tsh login --proxy (in which case it's clearly intentional that subsequent calls to tsh ssh pick up the port-forwarding configuration). I think the surprising behaviour is that tsh ssh -L sometimes behaves like tsh login --proxy (i.e. persistently saves the port-forwarding) and sometimes does not, depending on whether the user is initially logged in.

  • Teleport version: branch/v8
  • Recreation steps:
$ tsh ssh -L 8080:foo:8080 user@host  # while not logged in
$ < ~/.tsh/profile.yaml               # now my profile contains forward_ports
...
forward_ports:
- 8080:foo:8080

$ tsh ssh user@different-host         # in a different terminal
ERROR: Failed to bind to 127.0.0.1:8080: listen tcp 127.0.0.1:8080: bind: address already in use.

The answer here may be that this is working as expected, but thought I'd raise it as we found it surprising. Let me know if I can provide any more context 🙏

@craigfe craigfe added the bug label Oct 19, 2022
@moisesmejia1200 moisesmejia1200 added the c-af Internal Customer Reference label Nov 16, 2022
@gabrielcossette
Copy link

I confirm this bug is still present in v11.

@rottenbytes
Copy link

still there in v12 too

@pschisa pschisa added the c-dx Internal Customer Reference label May 10, 2023
@tardoe
Copy link

tardoe commented Jun 5, 2023

Still a bug in v13 as well.

❯ tsh version
Teleport v13.0.0 git:v13.0.0-0-g6d0ce2bf go1.20.4
Proxy version: 13.0.3

@zmb3
Copy link
Collaborator

zmb3 commented Jun 8, 2023

@r0mant @lxea this was fixed by #26823, right?

@lxea
Copy link
Contributor

lxea commented Jun 9, 2023

I think it should be, yeah

@zmb3 zmb3 closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c-af Internal Customer Reference c-dx Internal Customer Reference server-access
Projects
None yet
Development

No branches or pull requests

8 participants