From cf004cf72d0bd56fa32237b330a58cc1d308d756 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 12:44:57 -0800 Subject: [PATCH 1/7] fix: remove connection override flag --- frontend/types/gotypes.d.ts | 1 - pkg/remote/sshclient.go | 4 +--- pkg/wshrpc/wshrpctypes.go | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 5f71d73aa3..419c4ed6c7 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -309,7 +309,6 @@ declare global { type ConnKeywords = { "conn:wshenabled"?: boolean; "conn:askbeforewshinstall"?: boolean; - "conn:overrideconfig"?: boolean; "conn:wshpath"?: string; "conn:shellpath"?: string; "display:hidden"?: boolean; diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index ee4889d799..cf9d0b67c6 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -723,9 +723,7 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh. // cascade order: // ssh config -> (optional) internal config -> specified flag keywords -> parsed keywords partialMerged := sshConfigKeywords - if internalSshConfigKeywords.ConnOverrideConfig { - partialMerged = mergeKeywords(partialMerged, &internalSshConfigKeywords) - } + partialMerged = mergeKeywords(partialMerged, &internalSshConfigKeywords) partialMerged = mergeKeywords(partialMerged, connFlags) sshKeywords := mergeKeywords(partialMerged, parsedKeywords) diff --git a/pkg/wshrpc/wshrpctypes.go b/pkg/wshrpc/wshrpctypes.go index 9eb6e0c7ca..d1114b0374 100644 --- a/pkg/wshrpc/wshrpctypes.go +++ b/pkg/wshrpc/wshrpctypes.go @@ -484,7 +484,6 @@ type CommandRemoteWriteFileData struct { type ConnKeywords struct { ConnWshEnabled *bool `json:"conn:wshenabled,omitempty"` ConnAskBeforeWshInstall *bool `json:"conn:askbeforewshinstall,omitempty"` - ConnOverrideConfig bool `json:"conn:overrideconfig,omitempty"` ConnWshPath string `json:"conn:wshpath,omitempty"` ConnShellPath string `json:"conn:shellpath,omitempty"` From 2be9456cfba028d39229b3396eebc1161cf04d3d Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 14:39:21 -0800 Subject: [PATCH 2/7] feat: create default keyword function --- pkg/remote/sshclient.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index cf9d0b67c6..0785338f86 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -908,6 +908,31 @@ func findSshConfigKeywords(hostPattern string) (connKeywords *wshrpc.ConnKeyword return sshKeywords, nil } +func findSshDefaults(hostPattern string) (connKeywords *wshrpc.ConnKeywords, outErr error) { + sshKeywords := &wshrpc.ConnKeywords{} + + userDetails, err := user.Current() + if err != nil { + return nil, err + } + sshKeywords.SshUser = &userDetails.Username + sshKeywords.SshHostName = &hostPattern + sshKeywords.SshPort = utilfn.Ptr(ssh_config.Default("Port")) + sshKeywords.SshIdentityFile = ssh_config.DefaultAll("IdentityFile", hostPattern, ssh_config.DefaultUserSettings) // use the sshconfig here. should be different later + sshKeywords.SshBatchMode = utilfn.Ptr(false) + sshKeywords.SshPubkeyAuthentication = utilfn.Ptr(true) + sshKeywords.SshPasswordAuthentication = utilfn.Ptr(true) + sshKeywords.SshKbdInteractiveAuthentication = utilfn.Ptr(true) + sshKeywords.SshPreferredAuthentications = strings.Split(ssh_config.Default("PreferredAuthentications"), ",") + sshKeywords.SshAddKeysToAgent = utilfn.Ptr(false) + sshKeywords.SshIdentitiesOnly = utilfn.Ptr(false) + sshKeywords.SshIdentityAgent = utilfn.Ptr(ssh_config.Default("IdentityAgent")) + sshKeywords.SshProxyJump = strings.Split(ssh_config.Default("ProxyJump"), ",") + sshKeywords.SshUserKnownHostsFile = strings.Fields(ssh_config.Default("UserKnownHostsFile")) + sshKeywords.SshGlobalKnownHostsFile = strings.Fields(ssh_config.Default("GlobalKnownHostsFile")) + return sshKeywords, nil +} + type SSHOpts struct { SSHHost string `json:"sshhost"` SSHUser string `json:"sshuser"` From 33604e2e6ea41c5036d8d61c981e66c9fbb37dd5 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 14:48:20 -0800 Subject: [PATCH 3/7] feat: add config to disable parsing sshconfig --- pkg/remote/sshclient.go | 34 +++++++++++++++++++++++----------- pkg/wshrpc/wshrpctypes.go | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index 0785338f86..51dc8108f6 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -699,10 +699,29 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh. if jumpNum > SshProxyJumpMaxDepth { return nil, jumpNum, ConnectionError{ConnectionDebugInfo: debugInfo, Err: fmt.Errorf("ProxyJump %d exceeds Wave's max depth of %d", jumpNum, SshProxyJumpMaxDepth)} } - // todo print final warning if logging gets turned off - sshConfigKeywords, err := findSshConfigKeywords(opts.SSHHost) - if err != nil { - return nil, debugInfo.JumpNum, ConnectionError{ConnectionDebugInfo: debugInfo, Err: err} + + rawName := opts.String() + fullConfig := wconfig.GetWatcher().GetFullConfig() + internalSshConfigKeywords, ok := fullConfig.Connections[rawName] + if !ok { + internalSshConfigKeywords = wshrpc.ConnKeywords{} + } + + var sshConfigKeywords *wshrpc.ConnKeywords + if utilfn.SafeDeref(internalSshConfigKeywords.ConnIgnoreConfig) { + var err error + sshConfigKeywords, err = findSshDefaults(opts.SSHHost) + if err != nil { + err = fmt.Errorf("cannot determine default config keywords: %w", err) + return nil, debugInfo.JumpNum, ConnectionError{ConnectionDebugInfo: debugInfo, Err: err} + } + } else { + var err error + sshConfigKeywords, err = findSshConfigKeywords(opts.SSHHost) + if err != nil { + err = fmt.Errorf("cannot determine config keywords: %w", err) + return nil, debugInfo.JumpNum, ConnectionError{ConnectionDebugInfo: debugInfo, Err: err} + } } parsedKeywords := &wshrpc.ConnKeywords{} @@ -713,13 +732,6 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh. parsedKeywords.SshPort = &opts.SSHPort } - rawName := opts.String() - fullConfig := wconfig.GetWatcher().GetFullConfig() - internalSshConfigKeywords, ok := fullConfig.Connections[rawName] - if !ok { - internalSshConfigKeywords = wshrpc.ConnKeywords{} - } - // cascade order: // ssh config -> (optional) internal config -> specified flag keywords -> parsed keywords partialMerged := sshConfigKeywords diff --git a/pkg/wshrpc/wshrpctypes.go b/pkg/wshrpc/wshrpctypes.go index d1114b0374..af07f958a6 100644 --- a/pkg/wshrpc/wshrpctypes.go +++ b/pkg/wshrpc/wshrpctypes.go @@ -486,6 +486,7 @@ type ConnKeywords struct { ConnAskBeforeWshInstall *bool `json:"conn:askbeforewshinstall,omitempty"` ConnWshPath string `json:"conn:wshpath,omitempty"` ConnShellPath string `json:"conn:shellpath,omitempty"` + ConnIgnoreConfig *bool `json:"conn:ingoreconfig,omitempty"` DisplayHidden *bool `json:"display:hidden,omitempty"` DisplayOrder float32 `json:"display:order,omitempty"` From fe0a699af499ecaf3fa690ff223576282ae1b933 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 14:48:59 -0800 Subject: [PATCH 4/7] fix: add generated type --- frontend/types/gotypes.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 419c4ed6c7..ed324ad2dd 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -311,6 +311,7 @@ declare global { "conn:askbeforewshinstall"?: boolean; "conn:wshpath"?: string; "conn:shellpath"?: string; + "conn:ingoreconfig"?: boolean; "display:hidden"?: boolean; "display:order"?: number; "term:*"?: boolean; From df7123da790ece90598ea0807c933889394439ce Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 15:24:20 -0800 Subject: [PATCH 5/7] fix: typo in ignoreconfig --- frontend/types/gotypes.d.ts | 2 +- pkg/wshrpc/wshrpctypes.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index ed324ad2dd..09f41aa1fa 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -311,7 +311,7 @@ declare global { "conn:askbeforewshinstall"?: boolean; "conn:wshpath"?: string; "conn:shellpath"?: string; - "conn:ingoreconfig"?: boolean; + "conn:ignoreconfig"?: boolean; "display:hidden"?: boolean; "display:order"?: number; "term:*"?: boolean; diff --git a/pkg/wshrpc/wshrpctypes.go b/pkg/wshrpc/wshrpctypes.go index af07f958a6..9b35cd51a1 100644 --- a/pkg/wshrpc/wshrpctypes.go +++ b/pkg/wshrpc/wshrpctypes.go @@ -486,7 +486,7 @@ type ConnKeywords struct { ConnAskBeforeWshInstall *bool `json:"conn:askbeforewshinstall,omitempty"` ConnWshPath string `json:"conn:wshpath,omitempty"` ConnShellPath string `json:"conn:shellpath,omitempty"` - ConnIgnoreConfig *bool `json:"conn:ingoreconfig,omitempty"` + ConnIgnoreConfig *bool `json:"conn:ignoreconfig,omitempty"` DisplayHidden *bool `json:"display:hidden,omitempty"` DisplayOrder float32 `json:"display:order,omitempty"` From 7f3ed7a42296400f7fb445455fa1f4adf304ca4a Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 16:12:36 -0800 Subject: [PATCH 6/7] fix: rename to ignoresshconfig for clarity --- frontend/types/gotypes.d.ts | 2 +- pkg/remote/sshclient.go | 2 +- pkg/wshrpc/wshrpctypes.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 09f41aa1fa..52539b8a07 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -311,7 +311,7 @@ declare global { "conn:askbeforewshinstall"?: boolean; "conn:wshpath"?: string; "conn:shellpath"?: string; - "conn:ignoreconfig"?: boolean; + "conn:ignoresshconfig"?: boolean; "display:hidden"?: boolean; "display:order"?: number; "term:*"?: boolean; diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index 51dc8108f6..eb7fe2d50e 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -708,7 +708,7 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh. } var sshConfigKeywords *wshrpc.ConnKeywords - if utilfn.SafeDeref(internalSshConfigKeywords.ConnIgnoreConfig) { + if utilfn.SafeDeref(internalSshConfigKeywords.ConnIgnoreSshConfig) { var err error sshConfigKeywords, err = findSshDefaults(opts.SSHHost) if err != nil { diff --git a/pkg/wshrpc/wshrpctypes.go b/pkg/wshrpc/wshrpctypes.go index 9b35cd51a1..e531be39b3 100644 --- a/pkg/wshrpc/wshrpctypes.go +++ b/pkg/wshrpc/wshrpctypes.go @@ -486,7 +486,7 @@ type ConnKeywords struct { ConnAskBeforeWshInstall *bool `json:"conn:askbeforewshinstall,omitempty"` ConnWshPath string `json:"conn:wshpath,omitempty"` ConnShellPath string `json:"conn:shellpath,omitempty"` - ConnIgnoreConfig *bool `json:"conn:ignoreconfig,omitempty"` + ConnIgnoreSshConfig *bool `json:"conn:ignoresshconfig,omitempty"` DisplayHidden *bool `json:"display:hidden,omitempty"` DisplayOrder float32 `json:"display:order,omitempty"` From 735adbbc3cc53794f7ac4a76d6e737ed77c86100 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Tue, 21 Jan 2025 18:37:52 -0800 Subject: [PATCH 7/7] fix: use empty list for default proxyjump --- pkg/remote/sshclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index eb7fe2d50e..81d2640d0c 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -939,7 +939,7 @@ func findSshDefaults(hostPattern string) (connKeywords *wshrpc.ConnKeywords, out sshKeywords.SshAddKeysToAgent = utilfn.Ptr(false) sshKeywords.SshIdentitiesOnly = utilfn.Ptr(false) sshKeywords.SshIdentityAgent = utilfn.Ptr(ssh_config.Default("IdentityAgent")) - sshKeywords.SshProxyJump = strings.Split(ssh_config.Default("ProxyJump"), ",") + sshKeywords.SshProxyJump = []string{} sshKeywords.SshUserKnownHostsFile = strings.Fields(ssh_config.Default("UserKnownHostsFile")) sshKeywords.SshGlobalKnownHostsFile = strings.Fields(ssh_config.Default("GlobalKnownHostsFile")) return sshKeywords, nil