Commit Graph
200 Commits
Author SHA1 Message Date
Noah Stride af5e2517de Proxy Protocol support for Proxy SSH listener (#14712)
* Add additional debug logging for instantiation of ssh server conn

* Rough out introducing mux to ssh listener

* Catch errors from multiplexer serve

* Adapt multiplexer to support ProxyHelloSignature

* Adjust logging for ssh conn creation

* Adjust tests to use semantically correct assert/require helpers

* Address PR comments

* Check Client addr is properly propagated in mux test
2022-08-01 14:18:34 +00:00
Edward Dowling 3e8634cfec Fix chan_shutdown_read issue (#14736) 2022-07-29 18:47:39 +00:00
rosstimothy 9b22af6a5e SSH request tracing (#14124)
* SSH request tracing

Add tracing support for ssh global requests and  channels. Wrappers
for `ssh.Client`, `ssh.Channel`, and `ssh.NewChannel` provide a
mechanism for tracing context to be propagated via a `context.Context`.

In order to maintain backwards compatibility the ssh.Client wrapper
tries to open a TracingChannel when constructed. Any servers that
don't support tracing will reject the unknown channel. The client
will only provide tracing context to servers which do NOT reject
the TracingChannel request.

In order to include pass tracing context along all ssh payloads
are wrapped in an Envelope that includes the original payload
AND any tracing context. Servers now try to unmarshal all payloads
into said Envelope when processing messages. If there is an Envelope
provided, a new span will be created and the original payload will
be pass along to handlers.

Part of #12241
2022-07-27 14:56:06 +00:00
Russell Jones f09102312f Refactor tests under sshutils package.
Refactored all tests under "lib/sshutils" to use testify instead
of gocheck.
2022-07-22 12:06:02 -07:00
Noah Stride 02b4f8575f Configure linter to catch British 🇬🇧 spellings 🇺🇸 🦅 📖 (#14363)
* configure golangci-lint misspell to check for anglicized spellings

* Americanize spellings

* fix aws constant value with british spelling 🇬🇧

* update api types with americanized spellings

* use american spellings .cloudbuild/scripts
2022-07-14 10:51:23 +00:00
Brian Joerger ea87cb5730 X11 forwarding fixes for Mac and Windows (#14066) 2022-07-13 19:13:11 +00:00
Brian Joerger 8d80aa39bd Remove unnecessary X11 test that fails on MacOS (#13759) 2022-06-22 22:36:31 +00:00
Norbert SzeteiandZac Bergquist 0ab9716aac oss fuzz integration (#13473)
* Update api/types/fuzz_test.go
* do not fail if the file is missing
* missing go-118-fuzz-build fix

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-06-18 21:28:07 +00:00
Przemko Robakowski 951aff47ed IP-based validation for SSH (#13243)
This change adds IP-based validation for SSH certificates.
There's new option in role definition:

kind: role
metadata:
  name: dev
spec:
  options:
    pin_source_ip: true
When that is set to true client IP must be the same when generating certificates and using them. It uses source_address critical option that should be supported by both teleport and sshd and only applies to certificates we send to user (like in tsh login), we don't pin IP in certificates issued for web UI as they can't leak.
This change also omits machine ID (it uses different code path) - it will be added in separate PR.

Most of the lines changed are from regenerating types.proto, change itself is not that big

Relates #11719
2022-06-08 22:49:37 +00:00
Marco André Dinis 306d011151 Deprecate ca_signature_algo config (#13033)
After the merge of https://github.com/gravitational/teleport/pull/12674 we no longer use the following configuration:
```yaml
teleport:
    ca_signature_algo: "rsa-sha2-512"
```
As we now rely upon the `x/crypto` package to choose the signing algorithm (it defaults to `rsa-sha2-512`)

**Demo**
If we set `ca_signature_algo` (the value is irrelevant) and start `teleport` we get:
```shell
root@marco:/workspace# teleport start --debug
2022-06-02T09:33:58Z WARN             ca_signing_algo config option is deprecated and will be ignored, we'll always default to rsa-sha2-512. config/configuration.go:348
2022-06-02T09:33:58Z INFO             Generating new host UUID: b001159a-10e0-49a7-b4dc-61c73fbe9e42. service/service.go:726
...
```

Fixes #12905
2022-06-06 16:18:15 +01:00
David Boslee 32695a2f05 Add proxy peering support (#12359)
This adds proxy peering support. A configurable setting that allows for agents 
to connect to a subset of proxies and be reachable through any proxy in the
cluster. This is achieved by creating grpc connections between each proxy
server. Client connections can then be passed between proxies to the desired
agent.
2022-06-02 17:08:24 +00:00
Marco André Dinis 2493448cbd Bump x/crypto to 20220518 and remove custom algorithm signer (#12674)
This commit upgrades the version of x/crypto we use, to the current latest
`go get -u golang.org/x/crypto`

We also replaced the deprecated variables and updated the tests to match the
current default KEX Algos

The x/crypto didn't support RSA-SHA2 algos, so we developed our own algorithm
signer. This is no longer the case, and after upgrading x/crypto to 20220518 we
can safely remove the custom code we have.


From OpenSSH 8.8+, it works if we explicitly add the older algorithm
Somthing like this: `./ssh -vvv -oPubkeyAcceptedAlgorithms=+ssh-rsa-cert-v01@openssh.com teleportadmin@moon.marco.mydemo`
2022-05-25 14:47:00 +01: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
Gus Luxton 4af0edd06e ssh: Ignore PuTTY-specific channel requests (#12372)
When proxying connections, PuTTY automatically requests the 'simple@putty.projects.tartarus.org' channel
type to indicate that this is a "simple" connection which will not be requesting other channel formats.
A request to Teleport for this channel currently results in the connection being terminated. A better
idea is just to ignore this request.
2022-05-14 03:39:16 +00:00
Edoardo Spadolini 9d91466a0e Proxy restart fixes (#11802)
* Remove unused backend wrapper from Cache

* Remove double printShutdownStatus

* Fix readyz race condition

* Test coverage for the readyz.monitor fix

* Close listeners immediately in proxy.shutdown

* Use and handle net.ErrClosed correctly

This adapts utils.IsUseOfClosedNetworkError to check for net.ErrClosed
even inside trace.Aggregate errors, makes it so that we always return
something that would pass errors.Is(err, net.ErrClosed) when returning
from a (net.Listener).Accept(), and handles closed listeners within our
various Serve() loops so that we don't hit spurious backoff waits while
shutting down.

* Close listeners early and emitters late

* Test coverage for the proxy listener changes

* Revert some errors back to trace.ConnectionProblem

* Reduce PR scope to just the proxy, add comments

* Improve error logging.
2022-05-06 18:12:11 +02:00
Zac Bergquist 55cbd0ac97 Remove use of deprecated ioutil package (#11296)
* Remove use of deprecated ioutil package
* Add lint rule to check for ioutil imports
2022-03-21 18:00:34 +00:00
Brian Joerger 1b08e7d0db Handle case where display is itself a unix socket #10719 2022-03-08 23:51:59 +00:00
Brian Joerger a03d867771 Fix x11 server config issues (#10471) 2022-02-25 19:30:48 +00:00
Brian Joerger 172d7ed4c0 Update x11 sshserver test to test concurrent sessions and requests. (#10470) 2022-02-18 22:23:02 +00:00
Brian Joerger 8a4acb9ffe Replace /tmp with os.TempDir(). (#10322) 2022-02-14 18:39:22 +00:00
Brian Joerger d33f51d17f x11 forwarding (#9897) 2022-02-04 23:47:03 +00:00
Marek Smoliński fbd5a2aafd Fix tsh tctl do not load all CAS (#9357) 2022-01-31 13:35:15 +01:00
Alan Parra 85a6a0ca46 Improve SSH agent forwarding error message in proxy mode (#8829)
Proxy mode requires SSH agent forwarding permissions to work properly.
This tweaks the error message to mention that in a more direct manner.

Previous message:

$ tsh ssh mynode
> ERROR: failed connecting to node mynode. agent forwarding not requested or not authorized

New message:

$ tsh ssh mynode
> ERROR: failed connecting to node mynode. agent forwarding required in proxy recording mode
2021-11-10 13:33:28 -08:00
Forrest Marshall cf7d221b64 improve graceful restart behavior 2021-09-21 11:56:39 -07:00
Roman Tkachenko e1c3f80aa0 Fixes for cert checker and Postgres config builder (#8251) 2021-09-17 13:28:40 -07:00
Alan Parra dba49bfad6 Lint and fix missing license headers (#8075)
Introduce new make targets to check and add license headers to files
("make lint-license" and "make fix-license"). License checking is now a part of
"make lint" as well.

Initial attempts used goheader, but it caused "make lint-go" to become about 9x
slower (if not more), plus it only targets go files. Google's addlicense is fast
enough and targets however many file types we want.

Existing files that were missing licenses got the header added, using the
current year as the license date.

* Introduce lint-license and fix-license make targets
* Ignore generated files
* Add license to go files
* Replace irregular licenses with standard copyright/license
* Add license to proto files
* Install addlicense in build.assets Dockerfile
2021-08-30 09:44:09 -07:00
Nic Klaassen a8db09fe1e Use KeyStore instead of raw keys with CAs (#7615) 2021-08-03 10:13:08 -07:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Andrew Lytvynov d4247cb150 hsm: migrate CA storage schema (#7245)
* hsm: migrate CA storage schema

Migrate types.CertAuthorityV2 schema according to
https://github.com/gravitational/teleport/blob/master/rfd/0025-hsm.md#backend-storage

Includes proto changes, types.CertAuthority wrapper changes and data
migration.

Note that we keep and update the old fields for backwards-compatibility.
If a cluster is upgraded to v7 and then downgraded back to v6,
everything should keep working.

* Address review feedback
2021-06-16 12:17:03 -05:00
NajiObeid 86a6abcfcb lazy init of prometheus collectors (#6561)
* lazy init of prometheus collectors

* incorporate metrics intorduced in #6271

* linting

* tests

* pr changes

* tests

* pr changes
2021-05-19 11:53:36 -04:00
jane quin 7c9fd8e50d Add additional Prometheus Metrics (#6511) 2021-04-28 15:46:27 -07:00
Steven Martin b9b170042d Misspelling (#6503) 2021-04-21 06:01:41 -07:00
Brian Joerger 2beb991598 API client connection overhaul (#5625)
* Added support for connecting API client through tunnel proxy and web proxy addresses (with identity file).

* Added concurrent dialing logic to dial several possible dialing combinations and seamlessly return the first client to connect.
2021-03-23 14:39:20 -07:00
Andrew Lytvynov 6d8f778157 mfa: add WithMFA to session-related audit events (#5833)
* mfa: put device UUID in MFAVerified cert extensions

Instead of just a bool, add the device UUID. This will be used in audit
events when a session is started using MFA-issued certs.

* Add WithMFA to session-related audit events

Also extract a common function for parsing SSH certs.
2021-03-04 14:18:30 -08:00
dmitri ae4e5bfc97 Remove args as these can be deduced automatically 2021-03-03 17:49:12 -08:00
dmitri ca87f92ed5 Use non-greedy Mkdir variant and add a test-case for non-existing remote location with intermediate directories 2021-03-03 17:49:12 -08:00
dmitri ea4adc8b7e Add more test coverage for sink mode 2021-03-03 17:49:12 -08:00
dmitri fb8c71c6fa Check whether . is a base directory directly 2021-03-03 17:49:12 -08:00
dmitri 007235446f Use correct target directory path.
Handle target directory/file renames.

Fixes https://github.com/gravitational/teleport/issues/5695.
2021-03-03 17:49:12 -08:00
Andrew Lytvynov fc1c1dbd14 Move all utils.InitLoggerForTests calls to TestMain
This prevents data races between changing the standard logger and it
acutally being used.
2021-02-23 18:04:55 -08:00
a-palchikov e65eac59b0 tsh scp to use target directory correctly (#5501)
* Fixes the scp logic to take target directory into account in sink mode.
Also expose channel error in scp client so the error is more visible to
the user. Old behavior will only output the 'exit code n' if anything
breaks.

Fixes https://github.com/gravitational/teleport/issues/5497.

* Silence 'wait: remote command exited without exit status or exit signal' error when interrupting the scp session. Leave a TODO to fix properly in a future PR

* Address review comments
2021-02-11 19:35:40 +01:00
Andrew Lytvynov 5ca68f2351 Remove 'var _ = fmt.Printf' from *_test.go files (#5438)
These declarations serve no purpose, likely leftover from old debugging.
2021-01-29 17:01:10 -08:00
Brian Joerger efe91c4def api dependency reduction - ssh (#5379)
Move Cert Authority methods out of api to remove dependency on crypto/ssh.
2021-01-29 10:28:24 -08:00
Brian Joerger 626ad243eb api dependency reduction - utils constants (#5363)
Moved constants and utils used in /api into /api/constants and /api/utils respectively.
2021-01-29 09:37:01 -08:00
a-palchikov 43d142085e Wait on scp process at the end of the test. Service the stderr pipe to (#5418)
avoid 'broken pipe' in scp side.

Fixes https://github.com/gravitational/teleport/issues/5417.
2021-01-28 12:55:54 +01:00
a-palchikov 0ddde38df2 Suppress linter warning about unnecessary type conversion on darwin. (#5302) 2021-01-14 19:23:48 +01:00
a-palchikov 524c9483b3 Explicitly cast time values to int64 to enable 32-bit builds. (#5291)
Updates https://github.com/gravitational/teleport/pull/4764.
2021-01-14 11:10:47 +01:00
a-palchikov 72630d1df5 Implement support for preserving file times for 'tsh scp' (#4764)
* Add -p flag to scp
* Add support for preserving access/modification times on files/directories when copying files between hosts.
* lib/sshutils/scp: add time statting for directories
* Add directory handling for scp
* Rewrite scp tests with testify
* Address review comments
2021-01-06 13:21:06 +01:00
a-palchikov c94e5042c7 Server data race (#4790)
* Add logger attributes to be able to propagate logger from tests for identifying tests
* Add test case for Server's DeepCopy.
* Update test to using the testing package directly. Update dependency after upstream PR.
2020-12-09 16:46:33 +01:00