-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add canonically-cased config options
- Loading branch information
1 parent
c7f8dec
commit 840bd2c
Showing
2 changed files
with
149 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package ssh_config | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// Current as of OpenSSH 8.2 | ||
// Source: https://man.openbsd.org/ssh_config | ||
var configOptions = []string{ | ||
"Host", | ||
"Match", | ||
"AddKeysToAgent", | ||
"AddressFamily", | ||
"BatchMode", | ||
"BindAddress", | ||
"BindInterface", | ||
"CanonicalDomains", | ||
"CanonicalizeFallbackLocal", | ||
"CanonicalizeHostname", | ||
"CanonicalizeMaxDots", | ||
"CanonicalizePermittedCNAMEs", | ||
"CASignatureAlgorithms", | ||
"CertificateFile", | ||
"CheckHostIP", | ||
"Ciphers", | ||
"ClearAllForwardings", | ||
"Compression", | ||
"ConnectionAttempts", | ||
"ConnectTimeout", | ||
"ControlMaster", | ||
"ControlPath", | ||
"ControlPersist", | ||
"DynamicForward", | ||
"EnableSSHKeysign", | ||
"EscapeChar", | ||
"ExitOnForwardFailure", | ||
"FingerprintHash", | ||
"ForkAfterAuthentication", | ||
"ForwardAgent", | ||
"ForwardX11", | ||
"ForwardX11Timeout", | ||
"ForwardX11Trusted", | ||
"GatewayPorts", | ||
"GlobalKnownHostsFile", | ||
"GSSAPIAuthentication", | ||
"GSSAPIDelegateCredentials", | ||
"HashKnownHosts", | ||
"HostbasedAcceptedAlgorithms", | ||
"HostbasedAuthentication", | ||
"HostKeyAlgorithms", | ||
"HostKeyAlias", | ||
"Hostname", | ||
"IdentitiesOnly", | ||
"IdentityAgent", | ||
"IdentityFile", | ||
"IgnoreUnknown", | ||
"Include", | ||
"IPQoS", | ||
"KbdInteractiveAuthentication", | ||
"KbdInteractiveDevices", | ||
"KexAlgorithms", | ||
"KnownHostsCommand", | ||
"LocalCommand", | ||
"LocalForward", | ||
"LogLevel", | ||
"LogVerbose", | ||
"MACs", | ||
"NoHostAuthenticationForLocalhost", | ||
"NumberOfPasswordPrompts", | ||
"PasswordAuthentication", | ||
"PermitLocalCommand", | ||
"PermitRemoteOpen", | ||
"PKCS11Provider", | ||
"Port", | ||
"PreferredAuthentications", | ||
"ProxyCommand", | ||
"ProxyJump", | ||
"ProxyUseFdpass", | ||
"PubkeyAcceptedAlgorithms", | ||
"PubkeyAuthentication", | ||
"RekeyLimit", | ||
"RemoteCommand", | ||
"RemoteForward", | ||
"RequestTTY", | ||
"RevokedHostKeys", | ||
"SecurityKeyProvider", | ||
"SendEnv", | ||
"ServerAliveCountMax", | ||
"ServerAliveInterval", | ||
"SessionType", | ||
"SetEnv", | ||
"StdinNull", | ||
"StreamLocalBindMask", | ||
"StreamLocalBindUnlink", | ||
"StrictHostKeyChecking", | ||
"SyslogFacility", | ||
"TCPKeepAlive", | ||
"Tunnel", | ||
"TunnelDevice", | ||
"UpdateHostKeys", | ||
"User", | ||
"UserKnownHostsFile", | ||
"VerifyHostKeyDNS", | ||
"VisualHostKey", | ||
"XAuthLocation", | ||
} | ||
|
||
// // getConfigOptions retrieves a sorted list of all the current config options | ||
// // from the official source: https://man.openbsd.org/ssh_config and filtered | ||
// // with "github.com/PuerkitoBio/goquery". | ||
// // The result is sorted and therefore may be searched with sort.SearchStrings() | ||
// func getConfigOptions() (opts []string, err error) { | ||
// SSHConfigURL := "https://man.openbsd.org/ssh_config" | ||
|
||
// resp, err := http.Get(SSHConfigURL) | ||
// if err != nil { | ||
// return opts, fmt.Errorf("getting %s: %w", SSHConfigURL, err) | ||
// } | ||
// defer resp.Body.Close() | ||
|
||
// doc, err := goquery.NewDocumentFromReader(resp.Body) | ||
// if err != nil { | ||
// return opts, fmt.Errorf("parsing %s: %w", SSHConfigURL, err) | ||
// } | ||
|
||
// doc.Find("dt > a > code.Cm").Each(func(i int, c *goquery.Selection) { | ||
// opts = append(opts, c.Text()) | ||
// }) | ||
|
||
// sort.Strings(opts) | ||
// return opts, nil | ||
// } | ||
|
||
// GetCanonicalCase checks for the given key in the known ssh config keys | ||
// and returns with proper casing if found, otherwise returns what was given. | ||
func GetCanonicalCase(key string) string { | ||
for _, value := range configOptions { | ||
if strings.EqualFold(key, value) { | ||
return value | ||
} | ||
} | ||
return key | ||
} |