Skip to content

permissions not working for windows #6

Description

@manuel-84

this function doesnt work well on windows:

private async validateKeyPermissions(keyPath: string): Promise<void> {
    try {
      const stats = await fs.promises.stat(keyPath);
      const mode = stats.mode & 0o777;

      if (mode & 0o077) {
        throw new Error(
          `SSH key file has insecure permissions (${mode.toString(8)}). ` +
            `Required: 600 or 400. Fix with: chmod 600 ${keyPath}`
        );
      }
    } catch (err: unknown) {
      if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
        throw new Error(`SSH key file not found: ${keyPath}`);
      }
      throw err;
    }
  }

easy workaround to add in ssh-tunnel.ts to allow permissions in windows:

if (process.platform !== 'win32' && (mode & 0o077)) {
   ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions