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

Potential race condition. Unable to use tsh: the given private and public keys do not form a valid keypair #16494

Closed
fungiboletus opened this issue Sep 19, 2022 · 2 comments · Fixed by #26102
Labels
bug c-se Internal Customer Reference tsh tsh - Teleport's command line tool for logging into nodes running Teleport.

Comments

@fungiboletus
Copy link

fungiboletus commented Sep 19, 2022

Expected behavior:
It should work.

Current behavior:
It crashes with the following error messages:

 tsh version --debug
[KEYSTORE]  ERRO the given private and public keys do not form a valid keypair client/keystore.go:310
[CLIENT]    DEBU the given private and public keys do not form a valid keypair client/api.go:1056
Failed to fetch proxy version: the given private and public keys do not form a valid keypair
Teleport v10.2.2 git: go1.19.1
tsh logout --debug 
ERRO [KEYSTORE]  the given private and public keys do not form a valid keypair client/keystore.go:310
DEBU [CLIENT]    the given private and public keys do not form a valid keypair client/api.go:1056

ERROR REPORT:
Original Error: *trace.CompareFailedError the given private and public keys do not form a valid keypair
Stack Trace:
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/api/utils/keys/privatekey.go:225 github.com/gravitational/teleport/api/utils/keys.ParseKeyPair
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/api/utils/keys/privatekey.go:209 github.com/gravitational/teleport/api/utils/keys.LoadKeyPair
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/lib/client/keystore.go:308 github.com/gravitational/teleport/lib/client.(*FSLocalKeyStore).GetKey
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/lib/client/api.go:945 github.com/gravitational/teleport/lib/client.ReadProfileStatus
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/lib/client/api.go:1054 github.com/gravitational/teleport/lib/client.Status
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/tool/tsh/tsh.go:1679 main.onLogout
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/tool/tsh/tsh.go:999 main.Run
	/private/tmp/teleport-20220916-10028-11awu4w/teleport-10.2.2/tool/tsh/tsh.go:444 main.main
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/runtime/proc.go:250 runtime.main
	/opt/homebrew/Cellar/go/1.19.1/libexec/src/runtime/asm_arm64.s:1172 runtime.goexit
User Message: the given private and public keys do not form a valid keypair

Bug details:

  • Teleport version 10.2.2
  • Recreation steps ???
  • Debug logs

Reseting the ~/.tsh folder fixes the issue. I tried to see the diff of a working ~/.tsh folder with the broken one and I cannot see anything obvious. The files do not seem to be heavily corrupted. It could be very bad luck with one bit corruption somewhere, but I think it's better to report the issue in case more people experience it.

I'm suspecting it is a race condition error. I start VSCode with my Kubernetes plugin, and teleport starts the teleport login flow in the browser 3 times in parallel. It works most of the time but perhaps the race condition happens when writing the public and private keys files.

@fungiboletus fungiboletus changed the title Unable to use tsh: the given private and public keys do not form a valid keypair Potential race condition. Unable to use tsh: the given private and public keys do not form a valid keypair Sep 20, 2022
@samrees
Copy link

samrees commented Apr 24, 2023

This bug hits when you're using Lens, as it ends up launching one refresh per context programmatically. When there's a valid single sign-on session in the browser, they then complete in parallel as well.

@pschisa pschisa added c-se Internal Customer Reference tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Apr 24, 2023
@webvictim
Copy link
Contributor

Should be fixed by #26102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c-se Internal Customer Reference tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
4 participants