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

[v7] Add tsh config helper to generate OpenSSH client configuration (#7437) #7651

Merged
merged 2 commits into from
Jul 23, 2021

Conversation

timothyb89
Copy link
Contributor

  • Add tsh config ssh helper to generate OpenSSH client configuration

This adds a new subcommand, tsh config ssh, to generate OpenSSH
client configuration snippets that allow users to connect directly to
nodes using the standard ssh client.

To support this change, tsh's known_hosts file has been modified to
match the format required by OpenSSH when verifying hosts against
certificates. Old-style known_hosts entries will be automatically
replaced and pruned when the end user first logs in with an updated
tsh. Small changes were additionally made to the keystore and key
agent to pass the proxy host into AddKnownHostKeys and to support
wildcard hostnames in known_hosts entries.

  • Fix broken link to Trusted Clusters documentation

  • Use text/template for SSH config generation; wrap all errors.

  • Rename config helper from config ssh to just config

This changes the config helper to use just tsh config per
suggestion from @r0mant.

  • Fix known_hosts_migrate_test after rebase

  • First pass at review feedback

  • Update docs/pages/server-access/guides/openssh.mdx

Co-authored-by: Roman Tkachenko [email protected]

  • Ensure top-level hostnames never match wildcard patterns

  • Add additional host count check to canPruneOldHostsEntry.

  • Replace excess call to isOldStyleHostsEntry with documented invariant

  • Trim trailing dots on absolute hostnames in matchesWildcard

Co-authored-by: Roman Tkachenko [email protected]

* Add `tsh config ssh` helper to generate OpenSSH client configuration

This adds a new subcommand, `tsh config ssh`, to generate OpenSSH
client configuration snippets that allow users to connect directly to
nodes using the standard `ssh` client.

To support this change, tsh's `known_hosts` file has been modified to
match the format required by OpenSSH when verifying hosts against
certificates. Old-style `known_hosts` entries will be automatically
replaced and pruned when the end user first logs in with an updated
`tsh`. Small changes were additionally made to the keystore and key
agent to pass the proxy host into `AddKnownHostKeys` and to support
wildcard hostnames in `known_hosts` entries.

* Fix broken link to Trusted Clusters documentation

* Use text/template for SSH config generation; wrap all errors.

* Rename config helper from `config ssh` to just `config`

This changes the config helper to use just `tsh config` per
suggestion from @r0mant.

* Fix known_hosts_migrate_test after rebase

* First pass at review feedback

* Update docs/pages/server-access/guides/openssh.mdx

Co-authored-by: Roman Tkachenko <[email protected]>

* Ensure top-level hostnames never match wildcard patterns

* Add additional host count check to `canPruneOldHostsEntry`.

* Replace excess call to `isOldStyleHostsEntry` with documented invariant

* Trim trailing dots on absolute hostnames in `matchesWildcard`

Co-authored-by: Roman Tkachenko <[email protected]>
@timothyb89 timothyb89 changed the title Add tsh config helper to generate OpenSSH client configuration (#7437) [v7] Add tsh config helper to generate OpenSSH client configuration (#7437) Jul 22, 2021
Copy link
Contributor

@russjones russjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot.

@timothyb89 timothyb89 enabled auto-merge (squash) July 23, 2021 16:26
@timothyb89 timothyb89 merged commit bddcbc1 into branch/v7 Jul 23, 2021
@timothyb89 timothyb89 deleted the timothyb89/v7/ssh-config-helper branch July 23, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants