{"record":{"id":"73fc708230d4800f","repo":"pentaho/pentaho-kettle","slug":"could-not-get-user-name-on-remote-host-error-code","errorCode":null,"errorMessage":"Could not get user name on remote host (error code: )","messagePattern":"Could not get user name on remote host \\(error code: \\)","errorType":"exception","errorClass":"JSchException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/vfs/SftpFileSystemWindows.java","lineNumber":151,"sourceCode":"      if ( endIndex < 0 ) {\n        return result;\n      }\n      result.add( commandOutput.substring( startIndex, endIndex ).toUpperCase().trim() );\n    }\n  }\n\n  /**\n   * Get current user on remote host\n   *\n   * @return name of user on remote host\n   * @throws JSchException\n   * @throws IOException\n   */\n  String getUser() throws JSchException, IOException {\n    StringBuilder output = new StringBuilder();\n    int code = this.executeCommandWinClass( WHO_AMI, output );\n    if ( code != 0 ) {\n      throw new JSchException( \"Could not get user name on remote host (error code: \" + code + \")\" );\n    }\n\n    return output.toString().trim().toUpperCase();\n  }\n\n  /**\n   * @param path path to file or directory\n   * @return Map Windows Group - permissions\n   * @throws JSchException\n   * @throws IOException\n   */\n  Map<String, String> getFilePermission( String path ) throws JSchException, IOException {\n    String windowsAbsPath;\n    if ( path.startsWith( WINDOWS_PATH_DELIMITER ) ) {\n      //cut first \"/\" windows does not have it\n      //it mean first letter is name of disk\n      path = path.substring( WINDOWS_PATH_DELIMITER.length() );\n      windowsAbsPath = path.substring( 0, 1 ) + \":\" + path.substring( 1 );","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/vfs/SftpFileSystemWindows.java#L133-L169","documentation":"Thrown by SftpFileSystemWindows.getUser() when the remote 'whoami' command (WHO_AMI) exits with a non-zero code, so the remote user name cannot be determined. The user name is required to populate group/identity info on Windows SFTP connections.","triggerScenarios":"Any call chain that resolves the remote user (getUser, and therefore getUserGroups/userGroups) when 'whoami' returns non-zero on the remote Windows host.","commonSituations":"Same causes as the groups error: restricted remote shell, whoami.exe blocked or missing from PATH, non-Windows-class SSH server, account lacking execute rights.","solutions":["Manually run 'whoami' over SSH as the same account to reproduce and see the exit code","Verify the SSH server provides a Windows command shell (WinClass execution) and whoami.exe is on PATH","Unblock whoami.exe via security policy or antivirus exclusions","Use an account whose shell can execute whoami","Catch the JSchException and fall back to the username supplied in the VFS connection URI"],"exampleFix":"// before\nString user = fs.getUser();\n// after\nString user;\ntry {\n  user = fs.getUser();\n} catch ( JSchException | IOException e ) {\n  user = rootName.getUserName(); // fallback to configured username\n}","handlingStrategy":"try-catch","validationCode":"// ssh user@host \"whoami\" || echo WILL_FAIL","typeGuard":null,"tryCatchPattern":"try {\n  String user = fs.getUser();\n} catch ( JSchException | IOException e ) {\n  // fall back to the username from the connection URI\n}","preventionTips":["Confirm 'whoami' works over plain SSH with the same credentials","Use accounts whose shells are not restricted","Keep the Windows OpenSSH server default shell as cmd.exe or ensure WinClass execution works","Cache the username once resolved to avoid repeated remote calls"],"tags":["sftp","vfs","remote-execution","windows"],"backgroundTag":"http-request-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}