Building a Lightweight GTK4 ssh-askpass in Zig for Hardened Gentoo

A GTK4 SSH-askpass in Zig

Building a Lightweight GTK4 ssh-askpass in Zig for Hardened Gentoo

I developed a custom ssh-askpass tool using Zig and GTK4 to avoid heavy X11 or KDE dependencies on my hardened Gentoo system. Existing options in the Portage tree either required full desktop stacks or failed to compile without X support. This lightweight solution handles SSH key passphrases for non-TTY scenarios like Go builds without bloating my minimal Sway environment.

I did not want a full KDE stack on the machine just to type the occasional passphrase.
  1. danudey

    Noticed that when I build this it ends up with direct linking against a half-dozen libraries it doesn't actually use, at least on Ubuntu. Fixed it by replacing the linking commands with this:

    exe_mod.linkSystemLibrary("gtk-4", .{ .use_pkg_config = .no });

    exe_mod.linkSystemLibrary("gobject-2.0", .{});

    In my case, at least, this doesn't change the full library tree because gtk-4 still links against all of the libraries that are removed from this binary's list, but it does mean that programs which calculate dependencies, like dpkg-shlibdeps, won't report spurious "required" dependencies when analyzing the binary.

    When building on Ubuntu 26.04, the binary no longer directly links against lib{pango, cairo, pangocairo, cairo-gobject, harfbuzz, gdk_pixbuf, graphene, gio, vulkan}.

    Can't create an account on the site so I figured I'd post this here. If you're going for absolute minimalism this seems like another step in the right direction for anyone building on a more 'gratuitous' GTK build (such as Ubuntu's)

  2. DannyBee

    Whenever someone writes "with hand-written bindings" I read "will stop working 8 minutes after the next release"

  3. gen2brain

    Nice, I just use lxqt-openssh-askpass, but I am on X11. A lighter alternative (for single-text input) would be FLTK. Version 1.4 is really nice, with Wayland support, and they even draw custom window decorations on GNOME. Both Cairo and FLTK should be able to compile with -X; not sure, though, about the status of the Zig bindings.

More from this day

2026-07-31