Commit Graph
40 Commits
Author SHA1 Message Date
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
Jakub Nyckowski 5376f1a9aa Remove test keys (#19507)
A few of our tests that run certificate rotation fail with an error similar to this:

```
can only switch to phase update_clients from init, the current phase is
```

This happens when a duplicated private key is returned and set as a new key during CA rotation. During the CA rotation, we look for duplicated keys https://github.com/gravitational/teleport/blob/962e5a25bc56b5aad05528867182a43cd53cb551/lib/auth/rotate.go#L218 and try to rotate all of them at one. Because some of our tests use still use `testauthority` that only has 4 keys there is a huge chance that the same key will be returned twice, which causes the issue.
I swapped the logic to use a bigger pool with keys introduced in https://github.com/gravitational/teleport/pull/18750. I also removed the randomization part that, after some testing, I discovered was also causing some problems.

We could probably refactor the code in many tests now to make it simpler, but I want to keep this change as simple as possible. Otherwise, backporting bigger changes to older branches takes a long time.
2022-12-21 16:44:04 +00:00
Jakub Nyckowski 9379243390 Use pre-generated RSA keys in tests (#18750)
Many of our tests (db package, I'm looking at you) generate many RSA keys. This has two main side effects; makes our tests slow and flaky as CPU usage spikes in random moments when the tests are run in parallel.
This change pre-generates RSA keys at the beginning of each test module and reuse them in randomized order to reduce the situation that one key has been used multiple times in one test.
I had to move a few files to avoid circular dependencies.
2022-12-05 19:33:49 +00:00
Brian Joerger 3633b54723 cluster specific ssh-agent keys (#14677) 2022-11-18 00:52:56 +00:00
rosstimothy ebfbfd496e Use testauthority instead of native to generate keys in tests (#16486)
* use test authority

* use testauthority for InitConfig RSAKeyPairSource

* add named returns to test authority
2022-09-21 20:53:09 +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
Joel 99116409d4 Remove needlessly complex key generation scheme (#12113) 2022-04-25 09:26:10 +00:00
Andrew Lytvynovanda-palchikov 0f49d601a7 auth: API for requesting per-connection certificates (#5527)
* auth: API for requesting per-connection certificates

See https://github.com/gravitational/teleport/blob/master/rfd/0014-session-2FA.md#api

This API is a wrapper around GenerateUserCerts with a few differences:
- performs an MFA check before generating a cert
- enforces a single usage (ssh/k8s/db for now)
- embeds client IP in the cert
- marks a cert to distinguish from regular user certs
- enforces a 1min TTL

* Apply suggestions from code review

Co-authored-by: a-palchikov <deemok@gmail.com>

Co-authored-by: a-palchikov <deemok@gmail.com>
2021-02-10 20:29:00 -08:00
Brian Joerger ab3d1a11da Move /lib/wrappers to /api/types/wrappers. (#5286) 2021-01-14 14:58:44 -08:00
a-palchikov 6684c37103 Use fake clock consistently in units tests. (#5263)
Use fake clock consistently in units tests.
2021-01-12 12:10:00 +01:00
Andrew Lytvynov 18729d6ddc Add integration test for CA signature change
Also fix a few bugs along the way.
2020-06-24 21:25:33 +00:00
Forrest Marshall dfd40d21f5 proxy X11 forwarding support
- Role options now include a `permit_x11_forwarding` bool
which is set to `false` by default.

- Recording proxies now forward X11 requests and channels
when when permitted by RBAC.

- User certs will now include the `permit-X11-forwarding`
extension when permitted by RBAC.

- If X11 forwarding is requested for a session a new `x11`
audit event is emitted by recording proxies.
2020-06-24 11:40:47 -07:00
Sasha Klizhentas 83d0f7e7bb Fix role mapping for trusted clusters
This commit fixes #3252

Security patches 4.2 introduced a regression - leaf clusters ignore role mapping
and attempt to use role names coming from identity of the root cluster
whenever GetNodes method was used.

This commit reverts back the logic, however it ensures that the original
fix is preserved - traits and groups are updated on the user object.

Integration test has been extended to avoid the regression in the future.
2020-01-15 12:57:33 -08:00
Sasha Klizhentas 838e75468c Add support for ProxyJump.
This commit implements #2543

In SSH terms ProxyJump is a shortcut for SSH client
connecting the proxy/jumphost and requesting .port forwarding to the
target node.

This commit adds support for direct-tcpip request support
in teleport proxy service that is an alias to the existing proxy
subsystem and reuses most of the code.

This commit also adds support to "route to cluster" metadata
encoded in SSH certificate making it possible to have client
SSH certificates to include the metadata that will cause the proxy
to route the client requests to a specific cluster.

`tsh ssh -J proxy:port ` is supported in a limited way:

Only one jump host is supported (-J supports chaining
that teleport does not utilise) and tsh will return with error
in case of two jumphosts: -J a,b will not work.

In case if `tsh ssh -J user@proxy` is used, it overrides
the SSH proxy coming from the tsh profile and port-forwarding
is used instead of the existing teleport proxy subsystem
2019-07-26 10:58:11 -07:00
Russell Jones b139f72cab Create single instance of keygen per process. Use cache of precomputed
certificates when using recording proxy.
2018-02-15 21:23:30 +00:00
Russell Jones b3d4d36fde Added cert_format to role as well as tsh to control how a certificate is
generated.
2018-01-09 14:57:35 -08:00
Sasha Klizhentas c1153734b0 Add support for extra principals, fixes #1174
Add support for extra principals for proxy.
Proxy section already supports public_addr
property that is used during tctl users add
output.

Use the value from this property to update
host SSH certificate for proxy service.

proxy_service:
  public_addr: example.com:3024

With the configuration above, proxy host
certificate will contain example.com principal
in the SSH principals list.
2018-01-08 20:36:34 -08:00
Russell Jones 7018852c5d Added forwarding SSH server. 2017-12-04 17:01:52 -08:00
Sasha Klizhentas 0290cccb57 integration tests for proxies 2017-10-12 10:35:46 -07:00
Sasha Klizhentas 123a158f2e fix tests 2017-05-19 10:06:48 -07:00
Sasha Klizhentas f02d391172 add optional agent forward cert extension 2017-03-21 13:56:05 -07:00
Russell Jones 6295213815 Host certificate now presents two principals: hostUUID.clusterName and nodeName.clusterName. 2017-02-08 18:34:29 -08:00
Ev Kontsevoy d0e6e42015 Bufix: certificate expiration issue
This commit closes #529

Teleport was using nanoseconds to set the certificate expiration,
instead of milliseconds.

Changes:

- Switched from nanoseconds to seconds
- Switched from UTC to native time (because that's what golang/x/ssh
  uses internally)
2016-09-12 17:55:31 -07:00
Ev Kontsevoy 0b26b7fc47 Teleport Host Certificates support multiple roles now
Teleport CA-signed host certificates used to support only one
server role per cert.

This commit adds the ability to store multiple roles in a
certificate, paving the road for multi-role node support in
a near future.
2016-05-10 20:27:18 -07:00
Ev Kontsevoy cca475924b tsh now respects --user flag
Fixes #392
Fixes #396

Teleport now respects `--user` flag and, if --user is specified,
forces the certificate to belong to the given user.

This changes the file structure in `~/.tsh` directory. If a user logs in
under two different accounts, say "ekontsevoy" and "vince", it looks
like this:

```
~/.tsh/
├── keys
│   └── localhost
│       ├── ekontsevoy.cert
│       ├── ekontsevoy.key
│       ├── ekontsevoy.pub
│       ├── vince.cert
│       ├── vince.key
│       └── vince.pub
└── known_hosts

```

Also, to make tests more believable, I have added 3 more pre-generated
keys to 'testauthority' fixture, so instead of returning the same key
over and over, it now returns a random 1 of 4
2016-05-06 21:57:39 -07:00
Ev Kontsevoy b8788be4d4 Teleport was constantly asking for username+HOTP+password
The problem was in `time.Unix()` instead of `time.Unixnano()`
I'm not even sure how Unix() got in there...
2016-04-21 19:41:10 -07:00
Ev Kontsevoy e28f21922c Certificate TTL improvements
1. Server now always uses UTC timestamps for certificates it ussues
2. Client doesn't store cert validBefore time in separate files, it
   parses the cert itself.

Fixes #370
2016-04-19 16:09:22 -07:00
Ev Kontsevoy 5e80c2d662 Simple filesystem-based keystore for TSH
Started re-writing Teleport client keystore. From a buggy JSON-to-file
to a standard, directory/filebased API behind a standard interface to
allow for alternative implementations.

```
~/.tsh/
└── sessions
    └── localhost
        ├── cert
        ├── key
        └── pub
```
2016-04-18 22:56:21 -07:00
Ev Kontsevoy 3d42e3d636 Prepared previous commits for merging into master
- Fixed all tests
- Removed "magic constants" in random places
- Improved 'retry connecting to auth server' logic (it used to always
  fail on 1st attempt)
2016-04-11 16:32:38 -07:00
klizhentas 0e503ca376 Add proper integration with OpenSSH on both sides 2016-03-09 19:39:15 -08:00
klizhentas 278420174f refactor roles and certificates handling 2016-02-18 18:07:43 -08:00
Alex Lyulkov ed3a5088e8 Merged: added user mapping 2016-02-05 03:29:49 +03:00
Alex Lyulkov 566933b541 Fixed code style 2016-02-05 02:03:05 +03:00
Alex Lyulkov acd9cf4943 Added user mapping, web shell restarts after exit 2016-02-04 20:19:42 +03:00
Alex Lyulkov f3fef1b5d7 new keypairs precalculation with go channels 2016-01-30 01:44:43 +03:00
Alex Lyulkov a56b5236ac Moved to go1.5 vendoring 2016-01-20 18:52:25 +03:00
Alex Lyulkov 390714b842 Integrated permissions checker, replaced special tun requests by API calls. 2015-11-12 17:32:45 -08:00
klizhentas 00ef621e6b Apply apache license to teleport 2015-10-31 11:56:49 -07:00
Alex Lyulkov 6086af12af Storing precompiled tesing auth keys without encoding 2015-10-21 16:10:52 -07:00
Alex Lyulkov 8aec73d168 Added precompiled key genenators for backend and auth 2015-10-21 15:23:48 -07:00