mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 23:31:08 +08:00
* Add warning to previous command * Hash out basics of new tbot proxying command use * Avoid passing full botConfig into `tbot ssh-proxy-command` * wip * simplify impl * Set up test suite for ssh config generation * Add support for checking if ALPNConnUpgrade is required * Cache the alpn upgrade result * Americanize Spellings * Update lib/tbot/config/template_ssh_client.go Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com> * Add CHANGELOG.md entry for breaking change * Update tool/tbot/proxy.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Update lib/tbot/tbot.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Switch to `--no` variants rather than `={bool}` * Use SingleFlight on alpn proxy upgrade cache * Improve singleflight * Add rudimentary shell quoting * Uniformly pad the templating * Rename shellQuote -> proxyCommandQuote * Fix imports --------- Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
// Teleport
|
|
// Copyright (C) 2024 Gravitational, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gravitational/trace"
|
|
|
|
"github.com/gravitational/teleport/lib/tbot"
|
|
"github.com/gravitational/teleport/lib/tbot/config"
|
|
)
|
|
|
|
// onSSHProxyCommand is meant to be used as an OpenSSH/PuTTY proxy command. While this
|
|
// provides the same functionality as `tbot proxy ssh` it does so without invoking
|
|
// `tsh proxy ssh` which results in much less memory and cpu consumption. This will
|
|
// eventually supersede `tbot proxy ssh` as it becomes more feature rich and supports
|
|
// all the edge cases.
|
|
func onSSHProxyCommand(ctx context.Context, cf *config.CLIConf) error {
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
|
|
if cf.Port == "" {
|
|
cf.Port = "0"
|
|
}
|
|
|
|
proxySSHConfig := tbot.ProxySSHConfig{
|
|
DestinationPath: cf.DestinationDir,
|
|
Insecure: cf.Insecure,
|
|
FIPS: cf.FIPS,
|
|
ProxyServer: cf.ProxyServer,
|
|
Cluster: cf.Cluster,
|
|
User: cf.User,
|
|
Host: cf.Host,
|
|
Port: cf.Port,
|
|
EnableResumption: cf.EnableResumption,
|
|
TLSRoutingEnabled: cf.TLSRoutingEnabled,
|
|
ConnectionUpgradeRequired: cf.ConnectionUpgradeRequired,
|
|
TSHConfigPath: cf.TSHConfigPath,
|
|
Log: log,
|
|
}
|
|
|
|
return trace.Wrap(tbot.ProxySSH(ctx, proxySSHConfig))
|
|
}
|