-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implements RFD-0022 - OpenSSH-compatible Agent Forwarding #6525
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,40 +20,51 @@ import ( | |
"fmt" | ||
"strings" | ||
|
||
"github.com/gravitational/teleport/lib/client" | ||
"github.com/gravitational/teleport/lib/utils" | ||
|
||
"github.com/gravitational/trace" | ||
) | ||
|
||
const ( | ||
forwardAgentTextYes = "yes" | ||
forwardAgentTextNo = "no" | ||
forwardAgentTextLocal = "local" | ||
) | ||
|
||
// AllOptions is a listing of all known OpenSSH options. | ||
var AllOptions = map[string]map[string]bool{ | ||
"AddKeysToAgent": map[string]bool{"yes": true}, | ||
"AddressFamily": map[string]bool{}, | ||
"BatchMode": map[string]bool{}, | ||
"BindAddress": map[string]bool{}, | ||
"CanonicalDomains": map[string]bool{}, | ||
"CanonicalizeFallbackLocal": map[string]bool{}, | ||
"CanonicalizeHostname": map[string]bool{}, | ||
"CanonicalizeMaxDots": map[string]bool{}, | ||
"CanonicalizePermittedCNAMEs": map[string]bool{}, | ||
"CertificateFile": map[string]bool{}, | ||
"ChallengeResponseAuthentication": map[string]bool{}, | ||
"CheckHostIP": map[string]bool{}, | ||
"Cipher": map[string]bool{}, | ||
"Ciphers": map[string]bool{}, | ||
"ClearAllForwardings": map[string]bool{}, | ||
"Compression": map[string]bool{}, | ||
"CompressionLevel": map[string]bool{}, | ||
"ConnectionAttempts": map[string]bool{}, | ||
"ConnectTimeout": map[string]bool{}, | ||
"ControlMaster": map[string]bool{}, | ||
"ControlPath": map[string]bool{}, | ||
"ControlPersist": map[string]bool{}, | ||
"DynamicForward": map[string]bool{}, | ||
"EscapeChar": map[string]bool{}, | ||
"ExitOnForwardFailure": map[string]bool{}, | ||
"FingerprintHash": map[string]bool{}, | ||
"ForwardAgent": map[string]bool{"yes": true, "no": true}, | ||
"AddKeysToAgent": map[string]bool{"yes": true}, | ||
"AddressFamily": map[string]bool{}, | ||
"BatchMode": map[string]bool{}, | ||
"BindAddress": map[string]bool{}, | ||
"CanonicalDomains": map[string]bool{}, | ||
"CanonicalizeFallbackLocal": map[string]bool{}, | ||
"CanonicalizeHostname": map[string]bool{}, | ||
"CanonicalizeMaxDots": map[string]bool{}, | ||
"CanonicalizePermittedCNAMEs": map[string]bool{}, | ||
"CertificateFile": map[string]bool{}, | ||
"ChallengeResponseAuthentication": map[string]bool{}, | ||
"CheckHostIP": map[string]bool{}, | ||
"Cipher": map[string]bool{}, | ||
"Ciphers": map[string]bool{}, | ||
"ClearAllForwardings": map[string]bool{}, | ||
"Compression": map[string]bool{}, | ||
"CompressionLevel": map[string]bool{}, | ||
"ConnectionAttempts": map[string]bool{}, | ||
"ConnectTimeout": map[string]bool{}, | ||
"ControlMaster": map[string]bool{}, | ||
"ControlPath": map[string]bool{}, | ||
"ControlPersist": map[string]bool{}, | ||
"DynamicForward": map[string]bool{}, | ||
"EscapeChar": map[string]bool{}, | ||
"ExitOnForwardFailure": map[string]bool{}, | ||
"FingerprintHash": map[string]bool{}, | ||
"ForwardAgent": map[string]bool{ | ||
forwardAgentTextYes: true, | ||
forwardAgentTextNo: true, | ||
forwardAgentTextLocal: true, | ||
}, | ||
"ForwardX11": map[string]bool{}, | ||
"ForwardX11Timeout": map[string]bool{}, | ||
"ForwardX11Trusted": map[string]bool{}, | ||
|
@@ -114,6 +125,25 @@ var AllOptions = map[string]map[string]bool{ | |
"XAuthLocation": map[string]bool{}, | ||
} | ||
|
||
func asAgentForwardingMode(s string) client.AgentForwardingMode { | ||
switch strings.ToLower(s) { | ||
case forwardAgentTextNo: | ||
return client.ForwardAgentNo | ||
|
||
case forwardAgentTextYes: | ||
return client.ForwardAgentYes | ||
|
||
case forwardAgentTextLocal: | ||
return client.ForwardAgentLocal | ||
|
||
default: | ||
log.Errorf( | ||
"Invalid agent forwarding mode %q. Defaulting to %q", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Saw this after hitting Merge, will fix in new PR |
||
s, forwardAgentTextNo) | ||
return client.ForwardAgentNo | ||
} | ||
} | ||
|
||
// Options holds parsed values of OpenSSH options. | ||
type Options struct { | ||
// AddKeysToAgent specifies whether keys should be automatically added to a | ||
|
@@ -122,8 +152,8 @@ type Options struct { | |
|
||
// ForwardAgent specifies whether the connection to the authentication | ||
// agent will be forwarded to the remote machine. Supported option values | ||
// are "yes" and "no". | ||
ForwardAgent bool | ||
// are "yes", "no", and "local". | ||
ForwardAgent client.AgentForwardingMode | ||
|
||
// RequestTTY specifies whether to request a pseudo-tty for the session. | ||
// Supported option values are "yes" and "no". | ||
|
@@ -168,7 +198,7 @@ func parseOptions(opts []string) (Options, error) { | |
case "AddKeysToAgent": | ||
options.AddKeysToAgent = utils.AsBool(value) | ||
case "ForwardAgent": | ||
options.ForwardAgent = utils.AsBool(value) | ||
options.ForwardAgent = asAgentForwardingMode(value) | ||
case "RequestTTY": | ||
options.RequestTTY = utils.AsBool(value) | ||
case "StrictHostKeyChecking": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: (derived from https://github.com/golang/go/wiki/CodeReviewComments#error-strings). Let's make our log lines proper english sentences, so:
Selecting system key agent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw this after hitting Merge, will fix in new PR