<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanmilie</title>
    <description>The latest articles on DEV Community by Sanmilie (@sanmilie).</description>
    <link>https://dev.to/sanmilie</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3800351%2Ff9e7e315-339a-4db5-87ff-dd518df7a906.png</url>
      <title>DEV Community: Sanmilie</title>
      <link>https://dev.to/sanmilie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanmilie"/>
    <language>en</language>
    <item>
      <title>A native Windows SSH agent using CNG/KSP, with no dependencies, smartcard support, and full RDP compatibility</title>
      <dc:creator>Sanmilie</dc:creator>
      <pubDate>Sun, 01 Mar 2026 20:15:26 +0000</pubDate>
      <link>https://dev.to/sanmilie/a-native-windows-ssh-agent-using-cngksp-with-no-dependencies-smartcard-support-and-full-rdp-oae</link>
      <guid>https://dev.to/sanmilie/a-native-windows-ssh-agent-using-cngksp-with-no-dependencies-smartcard-support-and-full-rdp-oae</guid>
      <description>&lt;p&gt;Windows ships with a strong cryptographic subsystem (CNG/KSP), a mature certificate store, and enterprise identity mechanisms such as ADCS, TPM, Windows Hello, and smartcards.&lt;br&gt;
Despite this, Windows still lacks a modern SSH agent capable of using these identities.&lt;/p&gt;

&lt;p&gt;Existing solutions fall short in real environments:&lt;br&gt;
OpenSSH for Windows cannot use CNG/KSP keys or enterprise certificates.&lt;br&gt;
Pageant does not work reliably in RDP or multi-session environments.&lt;br&gt;
gpg-agent is not native to Windows and cannot use CNG/KSP or smartcards.&lt;br&gt;
OpenSC PKCS#11 modules do not integrate with the Windows Certificate Store.&lt;br&gt;
WinCryptSSHAgent is incomplete and unstable under load.&lt;br&gt;
For an OS used heavily in enterprise environments, this gap has been present for more than a decade.&lt;br&gt;
This project implements the missing piece.&lt;/p&gt;

&lt;p&gt;Overview&lt;br&gt;
SRO PKCS11 – SSH Agent CNG is a single Windows executable that unifies:&lt;br&gt;
a complete PKCS#11 module (Firefox, OpenSC, ssh -I)&lt;br&gt;
an OpenSSH-compatible SSH agent&lt;br&gt;
a Pageant-compatible server for PuTTY&lt;br&gt;
a CNG/KSP backend for smartcards, TPM, Windows Hello, and enterprise certificates&lt;br&gt;
a WSL2 TCP listener&lt;/p&gt;

&lt;p&gt;It has no external dependencies, no CRT, no DLLs, and no middleware.&lt;br&gt;
It works in RDP, RemoteApp, Citrix, multi-session, and hardened environments.&lt;/p&gt;

&lt;p&gt;Repository:&lt;br&gt;
&lt;a href="https://github.com/Sanmilie/PKCS11SSHAgent" rel="noopener noreferrer"&gt;https://github.com/Sanmilie/PKCS11SSHAgent&lt;/a&gt; (github.com in Bing)&lt;/p&gt;

&lt;p&gt;The problem: Windows cannot use enterprise identities for SSH&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enterprise certificates cannot be used for SSH
OpenSSH for Windows cannot use:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;non-exportable keys&lt;/li&gt;
&lt;li&gt;ADCS-issued certificates&lt;/li&gt;
&lt;li&gt;TPM-backed keys&lt;/li&gt;
&lt;li&gt;Windows Hello keys&lt;/li&gt;
&lt;li&gt;smartcards using CNG/KSP&lt;/li&gt;
&lt;li&gt;This forces administrators to generate private keys on disk, which is a security regression compared to enterprise identity standards.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Pageant is not ssh native&lt;br&gt;
Pageant requires a hidden window to function.&lt;br&gt;
Limited in PuTTY solution only&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;gpg-agent is not a Windows-native solution&lt;br&gt;
It does not support:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CNG/KSP&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows smartcard minidrivers&lt;/li&gt;
&lt;li&gt;enterprise certificates&lt;/li&gt;
&lt;li&gt;non-exportable keys&lt;/li&gt;
&lt;li&gt;multi-session environments&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;PKCS#11 modules do not integrate with the Windows Certificate Store
OpenSC cannot access:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;TPM-backed keys&lt;/li&gt;
&lt;li&gt;Windows Hello keys&lt;/li&gt;
&lt;li&gt;ADCS certificates&lt;/li&gt;
&lt;li&gt;Virtual Smartcards&lt;/li&gt;
&lt;li&gt;As a result, none of the existing tools can use the identities that Windows already manages securely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The solution: a unified, native, dependency-free agent&lt;br&gt;
This project provides a single executable that exposes:&lt;/p&gt;

&lt;p&gt;a full PKCS#11 module&lt;br&gt;
an SSH agent&lt;br&gt;
a Pageant server&lt;br&gt;
a WSL2 TCP bridge&lt;br&gt;
a CNG/KSP cryptographic backend&lt;/p&gt;

&lt;p&gt;All cryptographic operations are delegated to Windows.&lt;br&gt;
Private keys never leave the KSP.&lt;br&gt;
PIN entry is handled by the native Windows UI.&lt;/p&gt;

&lt;p&gt;Key properties&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native CNG/KSP integration&lt;/li&gt;
&lt;li&gt;Works in RDP and multi-session environments&lt;/li&gt;
&lt;li&gt;No dependencies, no CRT, no external DLLs&lt;/li&gt;
&lt;li&gt;Supports smartcards, TPM, Windows Hello, ADCS certificates&lt;/li&gt;
&lt;li&gt;Supports RSA, ECDSA, Ed25519, Ed448, Brainpool&lt;/li&gt;
&lt;li&gt;Supports PKCS#11 with 14 mechanisms&lt;/li&gt;
&lt;li&gt;Supports OpenSSH, Git for Windows, Visual Studio, PuTTY, WSL, WSL2&lt;/li&gt;
&lt;li&gt;Optional Windows service mode for hardened environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why this is the best option on Windows today&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Full CNG/KSP support&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The agent uses:&lt;/li&gt;
&lt;li&gt;NCryptSignHash&lt;/li&gt;
&lt;li&gt;the Windows Certificate Store&lt;/li&gt;
&lt;li&gt;smartcard minidrivers&lt;/li&gt;
&lt;li&gt;TPM and Hello providers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Private keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;are never exported&lt;/li&gt;
&lt;li&gt;never transit through the agent&lt;/li&gt;
&lt;li&gt;remain inside the KSP at all times&lt;/li&gt;
&lt;li&gt;PIN handling is performed entirely by Windows.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;RDP-safe and multi-session safe the agent:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;works in RDP&lt;/li&gt;
&lt;li&gt;works in RemoteApp&lt;/li&gt;
&lt;li&gt;works in Citrix&lt;/li&gt;
&lt;li&gt;works in multiple sessions&lt;/li&gt;
&lt;li&gt;works in non-interactive sessions&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;A single binary&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;No DLLs.&lt;/li&gt;
&lt;li&gt;No runtime.&lt;/li&gt;
&lt;li&gt;No external libraries.&lt;/li&gt;
&lt;li&gt;No registry pollution.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Complete PKCS#11 implementation
Compatible with:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Firefox&lt;/li&gt;
&lt;li&gt;pkcs11-tool&lt;/li&gt;
&lt;li&gt;ssh -I&lt;/li&gt;
&lt;li&gt;Any pcks11 enabled product&lt;/li&gt;
&lt;li&gt;Supports RSA, ECDSA, EdDSA, Brainpool, and PSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Complete SSH agent
Compatible with:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;OpenSSH&lt;/li&gt;
&lt;li&gt;Git for Windows&lt;/li&gt;
&lt;li&gt;Visual Studio&lt;/li&gt;
&lt;li&gt;VSCode Remote&lt;/li&gt;
&lt;li&gt;WSL&lt;/li&gt;
&lt;li&gt;WSL2 (via TCP 127.0.0.1:10022)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Pageant compatibility&lt;br&gt;
PuTTY, plink, pscp, psftp all work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optional Windows service mode&lt;br&gt;
For hardened or multi-user environments:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;service runs in session 0&lt;br&gt;
helper runs in the user session&lt;br&gt;
PIN UI appears in the correct session&lt;br&gt;
strict isolation between service and crypto operations&lt;/p&gt;

&lt;p&gt;Example: using an ADCS certificate for SSH&lt;br&gt;
Install the certificate in the Windows Certificate Store (non-exportable key).&lt;/p&gt;

&lt;p&gt;Start the agent.&lt;/p&gt;

&lt;p&gt;Export the public key:&lt;/p&gt;

&lt;p&gt;Code&lt;br&gt;
ssh-agent.exe -exportkey id.pub&lt;br&gt;
Add id.pub to authorized_keys on the server.&lt;/p&gt;

&lt;p&gt;Connect:&lt;/p&gt;

&lt;p&gt;Code&lt;br&gt;
ssh user@server&lt;br&gt;
No private key file.&lt;br&gt;
No token required.&lt;br&gt;
No additional configuration.&lt;/p&gt;

&lt;p&gt;Where this agent is most useful&lt;br&gt;
RDP / RemoteApp / Citrix environments&lt;/p&gt;

&lt;p&gt;Windows jump hosts&lt;/p&gt;

&lt;p&gt;PKI / ADCS administrators&lt;br&gt;
DevOps using Windows + WSL2&lt;br&gt;
Enterprises using smartcards (PIV/GIDS/YubiKey)&lt;br&gt;
Enterprises using TPM or Windows Hello&lt;br&gt;
Hardened workstations&lt;br&gt;
Windows-based CI pipelines&lt;/p&gt;

&lt;p&gt;Download&lt;br&gt;
&lt;a href="https://github.com/Sanmilie/PKCS11SSHAgent" rel="noopener noreferrer"&gt;https://github.com/Sanmilie/PKCS11SSHAgent&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>security</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
