{"record":{"id":"1f8e23ef7f04f185","repo":"wavetermdev/waveterm","slug":"user-selected-no","errorCode":null,"errorMessage":"user selected no","messagePattern":"user selected no","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/remote/sshclient.go","lineNumber":541,"sourceCode":"\t\t\t\"%s.\\n\\n\"+\n\t\t\t\"**Would you like to continue connecting?** If so, the key will be permanently \"+\n\t\t\t\"added to the file %s \"+\n\t\t\t\"to protect from future man-in-the-middle attacks.\", hostname, remote, key.Type(), base64Key, knownHostsFile)\n\trequest := &userinput.UserInputRequest{\n\t\tResponseType: \"confirm\",\n\t\tQueryText:    queryText,\n\t\tMarkdown:     true,\n\t\tTitle:        \"Known Hosts Key Missing\",\n\t}\n\treturn func() (*userinput.UserInputResponse, error) {\n\t\tctx, cancelFn := context.WithTimeout(ctx, 60*time.Second)\n\t\tdefer cancelFn()\n\t\tresp, err := userinput.GetUserInput(ctx, request)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif !resp.Confirm {\n\t\t\treturn nil, fmt.Errorf(\"user selected no\")\n\t\t}\n\t\treturn resp, nil\n\t}\n}\n\nfunc createMissingKnownHostsVerifier(knownHostsFile string, hostname string, remote string, key ssh.PublicKey) func() (*userinput.UserInputResponse, error) {\n\tbase64Key := base64.StdEncoding.EncodeToString(key.Marshal())\n\tqueryText := fmt.Sprintf(\n\t\t\"The authenticity of host '%s (%s)' can't be established \"+\n\t\t\t\"as **no known_hosts files could be found**. \"+\n\t\t\t\"The host you are attempting to connect to provides this %s key:  \\n\"+\n\t\t\t\"%s.\\n\\n\"+\n\t\t\t\"**Would you like to continue connecting?** If so:  \\n\"+\n\t\t\t\"- %s will be created  \\n\"+\n\t\t\t\"- the key will be added to %s\\n\\n\"+\n\t\t\t\"This will protect from future man-in-the-middle attacks.\", hostname, remote, key.Type(), base64Key, knownHostsFile, knownHostsFile)\n\trequest := &userinput.UserInputRequest{\n\t\tResponseType: \"confirm\",","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/sshclient.go#L523-L559","documentation":"createUnknownKeyVerifier builds a confirmation closure for a host whose key exists in no known_hosts file. When GetUserInput returns a response with Confirm == false, the closure fails with 'user selected no', aborting the host-key trust flow. The connection attempt is then cancelled instead of writing the key to known_hosts.","triggerScenarios":"First connection to a host not present in any configured known_hosts file, and the user dismisses/rejects the 'The authenticity of host ... can't be established' confirmation dialog within the 60-second prompt timeout window.","commonSituations":"New server provisioned and connected for the first time; headless/CI runs where the input UI auto-declines or times out; user noticing a key mismatch concern and declining.","solutions":["Reconnect and confirm the prompt with Yes to add the key to known_hosts.","Pre-seed the key via ssh-keyscan into the known_hosts file the app uses.","For non-interactive use, arrange an input provider that programmatically confirms, or pre-trust the host key."],"exampleFix":"// before\n// no known_hosts entry, user clicks No\n// after\n$ ssh-keyscan -H hostname >> ~/.ssh/known_hosts  # then reconnect","handlingStrategy":"try-catch","validationCode":"// check if the host is already trusted\nif !hostInKnownHosts(hostname, knownHostsFile) {\n    // expect a confirmation prompt; ensure a user or policy can answer Yes\n}","typeGuard":null,"tryCatchPattern":"if err := Connect(...); err != nil {\n    if strings.Contains(err.Error(), \"user selected no\") {\n        // prompt was declined; show guidance to accept or pre-trust the key\n    }\n}","preventionTips":["Add the host key to known_hosts ahead of first connection.","Ensure the UI/user-input provider is interactive so the prompt can be accepted.","Watch for the 60-second prompt timeout in slow-responding sessions."],"tags":["ssh","known-hosts","user-cancelled"],"backgroundTag":"host-key-verification-declined","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}