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

[v13] Fix PIV support for tsh proxy kube #30477

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pages/access-controls/guides/hardware-key-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ like `tctl edit`. With touch required, hardware key support provides better secu
- Standard Teleport API requests such as `tsh ls`, `tctl create`, and so on.
- Server access.
- Database access with `tsh proxy db` instead of `tsh db connect`.
- Kubernetes access with `tsh proxy kube` instead of `tsh kube login`.

Not yet supported:

- Teleport Web UI (except for user registration and reset password).
- Agent forwarding functionality such as `tsh ssh -A`, Proxy Recording mode, and OpenSSH integration.
- Kubernetes access.
- Desktop access.
- Application access.

Expand Down Expand Up @@ -238,7 +238,7 @@ Yubikey for Hardware Key support, you might get an error on rare occasions.
Depending on your settings, you might be asked to tap your Yubikey many times.
Each tap is necessary to safely authenticate you.

For example, if you have `second_factor: webauthn` set in your `cluster_auth_preference,
For example, if you have `second_factor: webauthn` set in your `cluster_auth_preference`,
and `require_session_mfa: hardware_key_touch` set on your role,
you'll see the following output when you first sign in:

Expand Down
6 changes: 1 addition & 5 deletions lib/client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,7 @@ func (k *Key) KubeTLSCert(kubeClusterName string) (tls.Certificate, error) {
if !ok {
return tls.Certificate{}, trace.NotFound("TLS certificate for kubernetes cluster %q not found", kubeClusterName)
}
keyPem, err := k.PrivateKey.RSAPrivateKeyPEM()
if err != nil {
return tls.Certificate{}, trace.Wrap(err)
}
tlsCert, err := keys.X509KeyPair(certPem, keyPem)
tlsCert, err := k.PrivateKey.TLSCertificate(certPem)
if err != nil {
return tls.Certificate{}, trace.Wrap(err)
}
Expand Down
12 changes: 4 additions & 8 deletions tool/tsh/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
apidefaults "github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/utils/keys"
"github.com/gravitational/teleport/lib/asciitable"
"github.com/gravitational/teleport/lib/auth/native"
"github.com/gravitational/teleport/lib/client"
"github.com/gravitational/teleport/lib/defaults"
"github.com/gravitational/teleport/lib/kube/kubeconfig"
Expand Down Expand Up @@ -171,7 +172,6 @@ func (c *proxyKubeCommand) printTemplate(cf *CLIConf, localProxy *kubeLocalProxy

type kubeLocalProxy struct {
tc *client.TeleportClient
profile *client.ProfileStatus
clusters kubeconfig.LocalProxyClusters
kubeConfigPath string

Expand Down Expand Up @@ -202,12 +202,9 @@ func makeKubeLocalProxy(cf *CLIConf, tc *client.TeleportClient, clusters kubecon
return nil, trace.Wrap(err)
}

keyPem, err := utils.ReadPath(profile.KeyPath())
if err != nil {
return nil, trace.Wrap(err)
}

localClientKey, err := keys.ParsePrivateKey(keyPem)
// Generate a new private key for the proxy. The client's existing private key may be
// a hardware-backed private key, which cannot be added to the local proxy kube config.
localClientKey, err := native.GeneratePrivateKey()
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -223,7 +220,6 @@ func makeKubeLocalProxy(cf *CLIConf, tc *client.TeleportClient, clusters kubecon

kubeProxy := &kubeLocalProxy{
tc: tc,
profile: profile,
clusters: clusters,
clientKey: localClientKey,
localCAs: cas,
Expand Down