-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ssh: fix relogin with jumphosts #6213
Conversation
@andrejtokarcik after a bit of tweaking, this change makes the following work:
I'm not confident that all of the changes are safe though, WDYT? |
8f45bc1
to
66f8061
Compare
Several fixes to make `tsh ssh -J leaf.proxy.com` work if the root cert is missing/expired.
Correctly parse trusted CAs on GetKey. Move retry without jumphosts from relogin to UpdateClusterCAs.
66f8061
to
0d12ddd
Compare
It doesn't seem to break anything.
1f632ef
to
1097859
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm but a question about the removed block.
// Override client's auth methods, current cluster and user name | ||
authMethod, err := key.AsAuthMethod() | ||
if err != nil { | ||
return trace.Wrap(err) | ||
} | ||
// After successful login we have local agent updated with latest | ||
// and greatest auth information, setup client to try only this new | ||
// method fetched from key, to isolate the retry | ||
tc.Config.AuthMethods = []ssh.AuthMethod{authMethod} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This messes up the relogin flow.
tc.Config.AuthMethods
is used as the first choice when connecting to a proxy over SSH.
If you were originally connecting to a leaf cluster (as in tsh ssh -J leaf.proxy.com somenode
) and relogin kicked in, you're be logged in via the root cluster (which is correct).
But after you've re-logged through the root cluster tc.Config.AuthMethods
would have an SSH cert for the root cluster, not for the leaf.
The cert caching and loading logic that @andrejtokarcik added correctly adds a leaf cert into the localAgent
, but it gets overriden by tc.Config.AuthMethods
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bot.
* ssh: fix relogin with jumphosts Several fixes to make `tsh ssh -J leaf.proxy.com` work if the root cert is missing/expired. * Address review feedback Correctly parse trusted CAs on GetKey. Move retry without jumphosts from relogin to UpdateClusterCAs. * Remove TelpoertClient.AuthMethods override on relogin It doesn't seem to break anything.
* ssh: fix relogin with jumphosts Several fixes to make `tsh ssh -J leaf.proxy.com` work if the root cert is missing/expired. * Address review feedback Correctly parse trusted CAs on GetKey. Move retry without jumphosts from relogin to UpdateClusterCAs. * Remove TelpoertClient.AuthMethods override on relogin It doesn't seem to break anything.
…e/dynamodb-gsi-autoscaling * 'master' of github.com:gravitational/teleport: (41 commits) Refactor ssh.ClientConfig used by tctl and API clients to use the first valid principal as User. Update Architecture Overview With Link To User Roles (#6224) Add `lint-api` target and fix lint errors (#6169) ssh: fix relogin with jumphosts (#6213) drone: use emptyDir for /var/lib/docker filesystem and prevent repetitive docker pulls (#6145) Remove ARM64 FIPS builds (#6236) tsh Profile SSH certs fix (#6214) mfa: fix gRPC unimplemented check in cert reissue Open Sources Access Controls Docs (#6188) (#6217) add PAM environment with interpolation support Cache per-cluster SSH certificates under ~/.tsh (#5938) add special resource type for access plugin data Enable DynamoDB autoscaling on global secondary indices (#6112) darwin fips builds (#5866) kube: add kubernetes_labels to role JSON schema mfa: send username instead of SSH login name in MFA cert request fix nil slice bug RFD 16: Add a section on `tctl rm` resetting resources back to defaults (#5673) Update application access docs (#6055) (#6137) Bump linux FIPS builds to use go1.16.2b7 release (#6143) ...
Several fixes to make
tsh ssh -J leaf.proxy.com
work if the root certis missing/expired.