@@ -699,10 +699,29 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh.
699699 if jumpNum > SshProxyJumpMaxDepth {
700700 return nil , jumpNum , ConnectionError {ConnectionDebugInfo : debugInfo , Err : fmt .Errorf ("ProxyJump %d exceeds Wave's max depth of %d" , jumpNum , SshProxyJumpMaxDepth )}
701701 }
702- // todo print final warning if logging gets turned off
703- sshConfigKeywords , err := findSshConfigKeywords (opts .SSHHost )
704- if err != nil {
705- return nil , debugInfo .JumpNum , ConnectionError {ConnectionDebugInfo : debugInfo , Err : err }
702+
703+ rawName := opts .String ()
704+ fullConfig := wconfig .GetWatcher ().GetFullConfig ()
705+ internalSshConfigKeywords , ok := fullConfig .Connections [rawName ]
706+ if ! ok {
707+ internalSshConfigKeywords = wshrpc.ConnKeywords {}
708+ }
709+
710+ var sshConfigKeywords * wshrpc.ConnKeywords
711+ if utilfn .SafeDeref (internalSshConfigKeywords .ConnIgnoreSshConfig ) {
712+ var err error
713+ sshConfigKeywords , err = findSshDefaults (opts .SSHHost )
714+ if err != nil {
715+ err = fmt .Errorf ("cannot determine default config keywords: %w" , err )
716+ return nil , debugInfo .JumpNum , ConnectionError {ConnectionDebugInfo : debugInfo , Err : err }
717+ }
718+ } else {
719+ var err error
720+ sshConfigKeywords , err = findSshConfigKeywords (opts .SSHHost )
721+ if err != nil {
722+ err = fmt .Errorf ("cannot determine config keywords: %w" , err )
723+ return nil , debugInfo .JumpNum , ConnectionError {ConnectionDebugInfo : debugInfo , Err : err }
724+ }
706725 }
707726
708727 parsedKeywords := & wshrpc.ConnKeywords {}
@@ -713,19 +732,10 @@ func ConnectToClient(connCtx context.Context, opts *SSHOpts, currentClient *ssh.
713732 parsedKeywords .SshPort = & opts .SSHPort
714733 }
715734
716- rawName := opts .String ()
717- fullConfig := wconfig .GetWatcher ().GetFullConfig ()
718- internalSshConfigKeywords , ok := fullConfig .Connections [rawName ]
719- if ! ok {
720- internalSshConfigKeywords = wshrpc.ConnKeywords {}
721- }
722-
723735 // cascade order:
724736 // ssh config -> (optional) internal config -> specified flag keywords -> parsed keywords
725737 partialMerged := sshConfigKeywords
726- if internalSshConfigKeywords .ConnOverrideConfig {
727- partialMerged = mergeKeywords (partialMerged , & internalSshConfigKeywords )
728- }
738+ partialMerged = mergeKeywords (partialMerged , & internalSshConfigKeywords )
729739 partialMerged = mergeKeywords (partialMerged , connFlags )
730740 sshKeywords := mergeKeywords (partialMerged , parsedKeywords )
731741
@@ -910,6 +920,31 @@ func findSshConfigKeywords(hostPattern string) (connKeywords *wshrpc.ConnKeyword
910920 return sshKeywords , nil
911921}
912922
923+ func findSshDefaults (hostPattern string ) (connKeywords * wshrpc.ConnKeywords , outErr error ) {
924+ sshKeywords := & wshrpc.ConnKeywords {}
925+
926+ userDetails , err := user .Current ()
927+ if err != nil {
928+ return nil , err
929+ }
930+ sshKeywords .SshUser = & userDetails .Username
931+ sshKeywords .SshHostName = & hostPattern
932+ sshKeywords .SshPort = utilfn .Ptr (ssh_config .Default ("Port" ))
933+ sshKeywords .SshIdentityFile = ssh_config .DefaultAll ("IdentityFile" , hostPattern , ssh_config .DefaultUserSettings ) // use the sshconfig here. should be different later
934+ sshKeywords .SshBatchMode = utilfn .Ptr (false )
935+ sshKeywords .SshPubkeyAuthentication = utilfn .Ptr (true )
936+ sshKeywords .SshPasswordAuthentication = utilfn .Ptr (true )
937+ sshKeywords .SshKbdInteractiveAuthentication = utilfn .Ptr (true )
938+ sshKeywords .SshPreferredAuthentications = strings .Split (ssh_config .Default ("PreferredAuthentications" ), "," )
939+ sshKeywords .SshAddKeysToAgent = utilfn .Ptr (false )
940+ sshKeywords .SshIdentitiesOnly = utilfn .Ptr (false )
941+ sshKeywords .SshIdentityAgent = utilfn .Ptr (ssh_config .Default ("IdentityAgent" ))
942+ sshKeywords .SshProxyJump = []string {}
943+ sshKeywords .SshUserKnownHostsFile = strings .Fields (ssh_config .Default ("UserKnownHostsFile" ))
944+ sshKeywords .SshGlobalKnownHostsFile = strings .Fields (ssh_config .Default ("GlobalKnownHostsFile" ))
945+ return sshKeywords , nil
946+ }
947+
913948type SSHOpts struct {
914949 SSHHost string `json:"sshhost"`
915950 SSHUser string `json:"sshuser"`
0 commit comments