Commit Graph
61 Commits
Author SHA1 Message Date
rosstimothy 1c3188a38a Add a dedicated client to communicate with the Proxy SSH server (#22629)
A new `api/client/proxy/Client` has been added to interact with
the SSH and gRPC servers that the Proxy serves on its SSH port.
The client will first try connecting to the gRPC server and if
that fails it will fall back to the SSH server.

Much of the SSH functionality mimics the existing behavior of the
`ProxyClient` in `lib/client`. This is the first part of phasing
out that client in favor of the new client. There will be a follow
up PR that migrates `lib/client` to make use of the new client instead.

Part of #19812
2023-03-15 13:41:56 +00:00
STeve (Xin) Huang 3a0ab15f4a Support App access behind load balancer (#22565)
* Support App access behind load balancer

* revert unecessary change

* fix lint

* Fix UT

* minor refactor
2023-03-14 13:47:41 +00:00
Andrew Burke 4b21199c7d Allow DialProxy to use TLS (#22439)
This change adds support for HTTPS proxies (i.e. `HTTPS_PROXY=https://...`).
2023-03-10 00:05:17 +00:00
Gavin Frazar ade99b7520 update tsh local proxy tunnel logic (#21779)
* check if --cert-file, --key-file are given when tunnel is required
* require tunnel mode for SQL Server and Cassandra
* deprecate --cert-file and --key-file flags in favor of --tunnel
2023-02-22 23:54:14 +00:00
STeve (Xin) Huang a8a069a93e Add athena-jdbc format to tsh proxy aws (#21811)
* AWS access: Athena JDBC support

* capture SplitHostPort error
2023-02-17 14:43:14 +00:00
Zac Bergquist c924be5c6d Refer to tsh apps subcommand (#21431)
The `tsh appps` family of commands is aliased to `tsh apps`, so both
invocations work correctly. The command itself is defined as `tsh apps`,
so this is what appears in the help message.

Update references to `tsh app` to recommend `tsh apps` instead so that
there isn't confusion when browsing `tsh help` and looking for a missing
`app` subcommand.

Fixes #21367
2023-02-10 21:40:55 +00:00
Gavin Frazar 4acf219b75 refactor db local proxy logic (#21196) 2023-02-06 18:55:23 +00:00
Gavin Frazar 3df617d989 fix tsh db connect with hardware backed key (#20806)
* Check key policy in tsh db connect flow

* Load key policy from identity file into temp profile
2023-01-30 23:29:47 +00:00
Krzysztof Skrzętnicki e053cba973 GCP CLI support: tsh and tctl changes (#19790) 2023-01-11 16:33:38 +00:00
STeve (Xin) Huang 286b8108b1 AWS Athena ODBC driver support for App Access (#19649) 2023-01-10 18:24:49 +00:00
Brian Joerger 488af75797 Client store generalization (#19420)
- Add a generalized client store made up of a key, profile, and trusted certs store. Each sub store can support different backends (~/.tsh, identity_file, in-memory). 
- Replace custom identity file handling with in-memory client store.
- Fix issues with trusted certs handling.
2023-01-06 01:34:04 +00:00
Steven Martin 331989dadf Add in allows ignoring missing DB CLIs like mysql which not all users have (#19762) 2023-01-02 11:01:34 +00:00
Gavin Frazar 5bb0ef15db add dynamodb database access (#18843)
* Add a new db engine
* Add tests for new engine
* Update tsh db subcommands
* Refactor error message and suggestions for unsupported tsh commands
* Add dynamodb to test plan
* Add AWS external ID to db config and update protos
2022-12-30 18:22:30 +00:00
Krzysztof Skrzętnicki dd67a49ab5 Azure CLI access (#18675) 2022-12-12 19:34:53 +00:00
Noah Stride f42e3f0b4a Enable HTTPS_PROXY support in tsh proxy ssh (#18204)
* Detect if HTTP_PROXY/HTTPS_PROXY is specified in `tsh proxy ssh`

* Support HTTPS_PROXY in `tsh proxy ssh`

* Ensure we tidy up connections on failure

* Lintering
2022-11-09 14:34:58 +00:00
Steven Martin 162ad51e3f Update proxy db message to give other option for connecting (#17891)
* Update message to give other option for connecting
2022-11-05 09:01:26 +00:00
Krzysztof Skrzętnicki d5ca90d9f2 Advise users about --port flag. (#17619) 2022-10-24 10:57:32 +00:00
Brian Joerger 23b893c2f2 Fix tsh proxy ssh -J leaf-proxy with root shutdown (#17571) 2022-10-20 17:47:34 +00:00
Marek Smoliński efb7f3e0de Fix tsh Cassandra pass condition (#17210) 2022-10-10 15:15:22 +00:00
Marek Smoliński 7aa224e430 Add Cassandra/Scylla database support (#15895) 2022-10-10 12:37:51 +02:00
Gavin Frazar ba7df65a0c support proxy db tunnel mfa access (#16958)
* Add local proxy middleware for db cert checking

* Use tls conversion util instead of inline

* Add middleware to local proxy config

* Add middleware configuration in tsh

* Use route to database check and set defaults func

* Dont trigger normal db login flow if using local proxy tunnel

* Split out adding client creds into helper func for testing

* Add integration test for local proxy tunnel db cert middleware

* Add unit test for local proxy middleware

* Update comment

* Make middleware on new conn block

* godoc

* Make any cert check error trigger cert renewal in local proxy middleware

* Move dbcertchecker into lib/client

* Remove unneeded mutex in local proxy and unused func in lib/utils

* Make local proxy middleware integration test more robust

* Print message before mfa prompt in proxy tunnel

* Add before prompt option to test

* Remove unneeded comment

* Change local proxy messages to be more clear

* Pass local proxy opts by reference

* Pass certs in opts instead of cert/key file path

This is so we can check if the error is recoverable while preparing
local proxy options. A tunneled local proxy can ignore the error because
it does not rely on cert files - it can just renew its certs if
necessary.

* Move db route checking back to tsh

* Fix lint err

* Fix typo and print the hint to same writer as the mfa prompt
2022-10-07 21:29:51 +00:00
Krzysztof Skrzętnicki af7cd0239d Elasticsearch: alternative clients (#16670) 2022-09-29 17:53:49 +00:00
Krzysztof Skrzętnicki 684956a06c Elasticsearch audit log support (#16191) 2022-09-23 11:46:15 +00:00
44b89c75c0 Elasticsearch support (#15768)
Co-authored-by: Anton Miniailo <anton@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-09-05 18:58:21 +02:00
STeve (Xin) Huang 8394f4fb48 ALPN connection upgrade for MySQL behind ALB (#15669) 2022-09-01 16:05:03 +00:00
Gabriel Corado a3a65e863b TLS routing ping for database protocols (#14887) 2022-08-26 16:42:23 +00:00
Brian Joerger 3a5a285883 Generalize private keys in tsh (PIV integration) (#15334)
Primary Changes:
 - Remove reliance on Private Key PEM:
 - Update native and keygen packages to return PrivateKey instead of PEM key
 - Add new PrivateKey interface which implements crypto.Signer
 - Replace PEM encoded private key usage where possible
 - Replace calls to tls.(Load)X509KeyPair with keys.(Load)X509KeyPair in
client packages

Minor Changes:
 - Remove unused agent.AddedKey return from LoadKey
 - Simplify sshutils and removed unused code paths
 - Add ecdsa and ed25519 key support
2022-08-25 23:26:44 +00:00
rosstimothy 0cb248ddd3 Trace ssh sessions (#14966)
Adds a wrapper around `ssh.Session` which injects tracing context
in a similar manner to the `ssh.Client` wrapper. All usages of
`ssh.Session` have now been replaced and have the appropriate
`context.Context` passed along

Part of #12241
2022-08-04 22:14:37 +00:00
Brian Joerger ee2fc31f5b Fix tsh proxy ssh handshake (#14771) 2022-07-28 17:59:19 +00:00
Roman Tkachenko 38b8bb4307 Add support for proxying TCP apps (#13455)
Add support for proxying tcp apps
2022-07-26 19:01:39 +00:00
Brian Joerger e707c52e91 Retry login for tsh proxy ssh (#14400) 2022-07-22 23:44:33 +00:00
STeve (Xin) Huang e8b0a05507 Allow "tsh proxy db" without "tsh db login" first (#14336) 2022-07-18 14:58:01 +00:00
Brian Joerger 45c977aea8 Replace ssh proxy execution with crypto/ssh call (#14222) 2022-07-15 00:59:27 +00:00
STeve (Xin) Huang 6981f8e8ac Add --format flag to "tsh proxy aws" (#13636) 2022-07-13 20:05:37 +00:00
STeve (Xin) Huang c18c09f5d5 Fix "tsh db ls --cluster cluster" to use the correct cluster name (#14334) 2022-07-12 17:03:18 +00:00
Brian Joerger c2a8ff3e78 Handle SHA1 certificates in ssh proxy command (#13956) 2022-07-01 18:39:48 +00:00
STeve (Xin) Huang 8cb7522aab Mongo clients with serverSelectionTimeoutMS set to 5000 (#13408) 2022-06-24 18:43:18 +00:00
rosstimothy e5c745f331 Add manual tracing instrumentation to tsh (#13204)
Create spans for all public facing TeleportClient,
ProxyClient, and NodeClient methods. This makes
correlating spans easier to reason about when
looking at `tsh` traces. As a result of creating
spans, some additional context propagation is
required as well to ensure that spans are linked
properly.

This also removes the unused `quiet` argument from
`ConnectToCluster`. It's usage was not consistent
by existing callers, and it was ignored, so in order
to avoid confusion in future calls, it was removed.

#12241
2022-06-11 15:34:40 +00:00
Roman Tkachenko ec512bafa4 Implement proxy templates (#12848) 2022-06-07 00:06:52 +00:00
Jakub NyckowskiandMarek Smoliński 9c046930ff Snowflake integration (#12564)
Add Snowflake integration.

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-06-06 17:49:38 +00:00
STeve (Xin) Huang 7a23fe80f9 Implement "tsh proxy aws" (#10025) 2022-06-03 19:14:34 +00:00
rosstimothy 9f094aaef6 Add tracing instrumentation for ssh clients/servers (#12434)
* Add tracing instrumentation for ssh clients/servers

Add tracing context to the existing ProxyHelloSignature to provide
span information across ssh connections. To add span context per
ssh session on top of new connections, the same tracing context is
passed in the first global request of the session.

In order to ensure that tracing context is pulled from and inserted
into the proper context.Context, some interfaces and methods were
changed to take one as the first argument.
2022-05-25 12:24:02 +00:00
Tim BuckleyandKrzysztof Skrzętnicki d873ea4fa6 Extend support for identity files in tsh (#12686)
* Extend support for identity files in tsh

This enhances support for identity files in tsh, which previously only
worked for regular SSH access. The largest blocker for support is that
tsh uses profiles for all non-SSH resource access, and profiles have a
direct mapping to some on-disk resources. This patch works around this
in a few ways:
 * Virtual profiles: When an identity file is specified with `-i`, we
   use it to create an in-memory virtual profile using the cert as the
   root identity _and_ for every `RouteToDatabase` (and in the future,
   app) field contained in the cert.
 * Virtual profile paths: Certain profile operations require paths to
   valid certificates and other resources on disk, which may not exist
   inside the identity file.

   As the driving use-case for this change is integration with Machine
   ID, we can "cheat" and pass the correct paths to tsh via
   environment variables. A cooperating wrapper in `tbot` will execute
   `tsh` with appropriate flags and environment variables, which
   override tsh's usual certifiate paths. This allows commands like
   `tsh db connect ...` to work as expected.
 * Key stores: previously we used a `noLocalKeyStore{}` with which all
   lookups fail. This patch replaces it with an in-memory keystore if
   a client key is available.
 * Profile status: lastly, we add a new `StatusCurrentWithIdentity()`
   function to load virtual profiles where supported. Some commands
   are not supported in this PR (like `tsh app ...`), but others
   don't make sense to support (like cert reissuing).

   We might consider merging everything into the traditional
   `StatusCurrent()` when adding app support.

App access is still broken and will be addressed in a later change.

Partially fixes #11770

* Fix failing lint

* Combine `StatusCurrentWithIdentity()` into `StatusCurrent()`

Additionally, log a warning when environment variable paths aren't
found.

* Fix virtual profile flag always being true

* Update lib/client/api.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Address review feedback

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
2022-05-24 21:40:03 +00:00
Jakub NyckowskiandMarco André Dinis 8230cc41e2 Add MySQL ALPN proto to 'tsh proxy db' (#12344)
Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
2022-05-02 12:45:32 -04:00
d5d2a72ace Advertise correct MySQL server version (#12196)
Teleport now will try to extract MySQL server version from initial handshake package instead of sending `8.0.0-Teleport` every time. This string can be overridden by new configuration option `mysql.server_version`. On DB service start Teleport will also try to fetch the current version from MySQL/MariaDB instance. After that the server version will be updated on every successful connection to keep it up to date.

Co-authored-by: STeve (Xin) Huang <xin.huang@goteleport.com>
Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
2022-04-29 22:22:11 +00:00
Rafał Cieślak 60f59725a9 Generate DB CLI commands for Teleterm from tsh daemon (#11835)
* Extract dbcmd.go into a new package under lib/client/db/dbcmd

* Use dbcmd to generate CliCommand for gateways

* Return relative db command from tsh daemon

* Add WithTolarateMissingCLIClient func to dbcmd
2022-04-14 08:29:26 +00:00
Roman Tkachenko 97c0b5cb83 Add auth'd tunnel mode to tsh proxy db command (#11720) 2022-04-07 18:33:39 +00:00
Logan Davis 0602d7661f Adds application proxy to tsh (#10509) 2022-02-23 20:29:54 -06:00
Roman Tkachenko 41899806fd Add SQL Server support for database access (#10097) 2022-02-17 02:20:33 +00:00
Jakub Nyckowski 530ff4c402 Add Redis integration (#10053)
Add support for Database Access for Redis for standalone and cluster self-hosted instances. Teleport requires mTLS in order to connect to Redis instance which is only supported in Redis 6.0+. RESP2 is currently the only supported protocol.
2022-02-16 13:32:32 -05:00