Skip to content

Instantly share code, notes, and snippets.

@jkroepke
Last active March 19, 2025 17:14
Show Gist options
  • Save jkroepke/cbf4c4bb5c649353fae72ce4ae6483a0 to your computer and use it in GitHub Desktop.
Save jkroepke/cbf4c4bb5c649353fae72ce4ae6483a0 to your computer and use it in GitHub Desktop.

gcc ssh-askpass.c -o ssh-askpass.exe -Os -flto -s -ffunction-sections -fdata-sections -Wl,--gc-sections -nostartfiles -fno-ident -ffreestanding -nostdlib

#include <stdio.h>
#include <stdlib.h>
int main() {
const char *filePath = getenv("SSH_ASKPASS_FILE");
if (!filePath) return 1;
FILE *file = fopen(filePath, "rb");
if (!file) return 1;
char buffer[256];
if (!fgets(buffer, sizeof(buffer), file)) {
fclose(file);
return 1;
}
fclose(file);
// Trim newlines
for (char *p = buffer; *p; ++p)
if (*p == '\n' || *p == '\r')
*p = '\0';
puts(buffer);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment