Encasha: Layer-2 Namecoin Verification of SSH Host Keys
Encasha enables SSH clients (e.g. OpenSSH) to automatically verify host keys for Namecoin domains, without putting SSHFP records on-chain. Encasha works by stapling a Namecoin message signature in an SSH certificate extension.
Building
-
Ensure you have the Go tools installed.
-
Clone encasha.
-
Run go install ./.... encasha will be built. The binaries will be at $GOPATH/bin/encasha.
Installing in OpenSSH
KnownHostsCommand /usr/bin/encasha --reason "%I" --host "%H" --key "%K"
Configuration
Encasha uses Namecoin Core cookie authentication by default. If you have a non-default Namecoin RPC port, cookie path, or username/password, these can be set via a TOML configuration file in $HOME/.config/encasha/encasha.conf.
Encasha uses “strict” mode by default; this enforces an STS-like policy for all Namecoin domains (i.e. any domains under the bit and bit.onion eTLD’s). This unfortunately will also break Namecoin domains that use on-chain SSHFP records. If you must use on-chain SSHFP records, you can disable strict mode via TOML config.
TODO: document/improve this.
Certificate Generation
Generate a domain CA:
ssh-keygen -f ./example.bit_ca_key -C 'example.bit Domain CA'
Generate a host key:
ssh-keygen -f ./example.bit_host_key -C 'example.bit Host Key'
Get the base64-encoded key:
cat example.bit_ca_key.pub
Sign the following message with Namecoin:
Namecoin SSH Stapled Certification: {"address":"FILL IN NAMECOIN ADDRESS HERE BEFORE SIGNING","domain":"example.bit","sshpub":"FILL IN SSH CA BASE64 PUBKEY HERE BEFORE SIGNING"}
Sign the host key with the domain CA:
ssh-keygen -h -s ./example.bit_ca_key -I 'example.bit Host Certificate' -n example.bit -O 'extension:[email protected]=[{"blockchainaddress":"FILL IN NAMECOIN ADDRESS HERE BEFORE SIGNING","blockchainsig":"FILL IN NAMECOIN SIGNATURE HERE BEFORE SIGNING"}]' ./example.bit_host_key.pub
Inspect the cert:
ssh-keygen -L -f example.bit_host_key-cert.pub
Add the cert to the server:
HostCertificate ./example.bit_host_key-cert.pub
Certificate Revocation
Transfer your Namecoin name to a new address to revoke all SSH certifications. (As a corollary, if you want to update your name without revoking SSH certifications, you must reuse the same Namecoin address.)
Relationship to Encaya
Encasha does for SSH what Encaya’s off-chain mode does for X.509. Encasha and Encaya share the same underlying codebase for validating stapled Namecoin certifications. Encaya’s on-chain modes are not applicable to SSH because SSH implementations already support that functionality natively (via the SSHFP DNS record type).
Theoretical Background
See Namecoin’s 38C3 talks.
Licence
Copyright © 2025 Namecoin Developers.
Encasha is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Encasha is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Encasha. If not, see https://www.gnu.org/licenses/.
评论