RSA(1)
π RSA(1) π
okay so bestie, welcome to the General Commands Manual page for the whole key-making squad. This is RSA(1), and it is literally giving βgenerate and format DSA and RSA keysβ with main character energy. No cap: every command, flag, example and warning is still here, just with more sparkle β¨.
πΈ NAME πΈ
dsagen, rsagen, rsafill, asn12dsa, asn12rsa, dsa2pub, rsa2csr, rsa2pub, dsa2ssh, rsa2ssh, rsa2x509 β generate and format dsa and rsa keys.
β¨ SYNOPSIS β¨
dsagen [ -t tag ]
rsagen [ -b nbits ] [ -t tag ]
rsafill [ file ]
asn12dsa [ -t tag ] [ file ]
asn12rsa [ -t tag ] [ file ]
dsa2pub [ file ]
rsa2pub [ file ]
dsa2ssh [ file ]
rsa2ssh [ -2 ] [ file ]
rsa2x509 [ -e expiretime ] certinfo [ file ]
rsa2csr certinfo [ file ]
π DESCRIPTION π
Plan 9 represents DSA and RSA keys as attribute-value pair lists prefixed with the string key; this is the generic key format used by factotum(4). A full DSA private key has the following attributes:
protoβ must bedsapβ prime public modulusqβ prime group order; dividesp-1alphaβ group generatorkeyβalpha^!secret mod p!secretβ the secret exponent
A full RSA private key has the following attributes:
protoβ must bersasizeβ the number of significant bits innekβ the encryption exponentnβ the product of!pand!q!dkβ the decryption exponent!pβ a large prime!qβ another large prime!kp,!kq,!c2β parameters derived from the other attributes, cached to speed decryption
All the numbers in both keys are in hexadecimal except RSA's size, which is decimal. A public key omits the attributes beginning with !. A key may have other attributes as well (for example, a service attribute identifying how this key is typically used), but to these utilities such attributes are merely comments.
For example, a very small (and thus insecure) private key and corresponding public key might be:
key proto=rsa size=8 ek=7 n=8F !dk=67 !p=B !q=D !kp=3 !kq=7 !c2=6
key proto=rsa size=8 ek=7 n=8F
Note that the order of the attributes does not matter.
β οΈ vibe check: that example key is very small and thus insecure β it is a demo, not a flex, bestie π.
dsagen prints a randomly generated DSA private key using the NIST-recommended algorithm. If tag is specified, it is printed between key and proto=dsa; typically, tag is a sequence of attribute-value comments describing the key.
rsagen prints a randomly generated RSA private key whose n has exactly nbits (default 1024) significant bits.
rsafill reads a private key, recomputes the !kp, !kq, and !c2 attributes if they are missing, and prints a full key.
asn12dsa reads a DSA private key stored as ASN.1 encoded in the binary Distinguished Encoding Rules (DER) and prints a Plan 9 DSA key, inserting tag exactly as dsagen does. ASN.1/DER is a popular key format on Unix and Windows; it is often encoded in text form using the Privacy Enhanced Mail (PEM) format in a section labeled as a DSA PRIVATE KEY. The command:
pemdecode 'DSA PRIVATE KEY' | asn12dsa
extracts the key section from a textual ASN.1/DER/PEM key into binary ASN.1/DER format and then converts it to a Plan 9 DSA key.
asn12rsa is similar but operates on RSA keys.
dsa2pub reads a Plan 9 DSA public or private key, removes the private attributes, and prints the resulting public key. Comment attributes are preserved.
rsa2pub is similar but operates on RSA keys.
dsa2ssh reads a Plan 9 DSA public or private key and prints the public portion in the format used by SSH version 2 (version 1 did not support DSA). If the key has a comment attribute, that comment is appended to the key.
rsa2ssh is similar but operates on RSA keys. It decides whether to print in version 1 or version 2 format by inspecting the service attribute.
dsa2ssh and rsa2ssh are useful for generating SSH's authorized_keys file.
rsa2x509 reads a Plan 9 RSA private key and writes a self-signed X.509 certificate encoded in ASN.1/DER format to standard output. (Note that ASN.1/DER X.509 certificates are different from ASN.1/DER private keys.) The certificate uses the current time as its start time and expires expiretime seconds (default 3 years) later. It contains the public half of the key and includes certinfo as the issuer/subject string (also known as a Distinguished Name). This info is typically in the form:
C=US ST=NJ L=07974 O=Lucent OU='Bell Labs' CN=G.R.Emlin
The X.509 ASN.1/DER format is often encoded in text using a PEM section labeled as a CERTIFICATE. The command:
rsa2x509 'C=US OU=''Bell Labs''' file |
pemencode CERTIFICATE
generates such a textual certificate. Applications that serve TLS-encrypted sessions typically expect certificates in ASN.1/DER/PEM format.
rsa2csr is like rsa2x509 but writes an X.509 certificate request.
π EXAMPLES π
Generate a fresh key and use it to start the Plan 9 TLS-enabled web server:
rsagen -t 'service=tls owner=*' >key
rsa2x509 'C=US CN=*.cs.bell-labs.com' key |
pemencode CERTIFICATE >cert
cat key >/mnt/factotum/ctl
ip/httpd/httpd -c cert
Generate a fresh set of SSH keys (only one is necessary), load them into factotum, and configure a remote Unix system to allow those keys for logins:
rsagen -t 'service=ssh role=decrypt' >rsa1
rsagen -t 'service=ssh-rsa role=sign' >rsa2
dsagen -t 'service=ssh-dss role=sign' >dsa2
Convert existing Unix SSH version 2 keys instead of generating new ones:
cd $HOME/.ssh
pemdecode 'DSA PRIVATE KEY' id_dsa | asn12dsa >dsa2
pemdecode 'RSA PRIVATE KEY' id_rsa | asn12rsa >rsa2
Load those keys into factotum:
cat rsa1 rsa2 dsa2 | 9p write -l factotum/ctl
Allow use of those keys for logins on other systems:
rsa2ssh rsa1 >auth.keys
rsa2ssh rsa2 >>auth.keys
dsa2ssh dsa2 >>auth.keys
scp auth.keys unix:.ssh/authorized_keys
π¦ SOURCE π¦
/src/cmd/auth β that is the source, bestie π«Ά.
π SEE ALSO π
factotum(4), pem(1), ssh(1) β the supporting cast, go read them too β¨.
π BUGS π
- There are too many key formats.
- There is no program to convert SSH version 1 RSA private keys.
and that's the footer, bestie: xoxo, RSA(1) from the General Commands Manual πβ¨π«Ά
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms