SSH-TPM-KEYGEN(1)
β¨ SSH-TPM-KEYGEN(1) β¨
okay so bestie, welcome to the ssh-tpm-keygen manual page β part of the ssh-tpm-agent manual, and honestly? it's giving "small utility, big responsibilities" π
. sit down, grab a strawberry π, and let's get into it.
πΈ SYNOPSIS πΈ
ssh-tpm-keygen [OPTIONS]...
ssh-tpm-keygen --wrap PATH --wrap-with PATH
ssh-tpm-keygen --import PATH
ssh-tpm-keygen --print-pubkey PATH
ssh-tpm-keygen --supported
ssh-tpm-keygen -p [-f keyfile] [-P old passphrase] [-N new passphrase]
ssh-tpm-keygen -A [-f path prefix] [--hierarchy hierarchy]
like, pick a lane, any lane π β each of those lines is a totally valid way to run it.
π¦ DESCRIPTION π¦
ssh-tpm-keygen is the program that lets you create TPM wrapped keys for ssh-tpm-agent. that's the whole vibe. it makes keys, the TPM seals them, you go live your life. no cap. β¨
π OPTIONS π
-Aβ generate host keys for all the key types (rsa and ecdsa). both of them. at once. main character energy π-b BITSβ how many bits in the key you're creating:- rsa:
2048(default) - ecdsa:
256(default) |384|521
- rsa:
-C COMMENTβ give the key a comment, y'know, a lil name tag π-f PATHβ the output keyfile path.-N PASSPHRASEβ passphrase for the key.-o,--owner-password PASSPHRASEβ ask for the owner password. π-t [ecdsa | rsa]β pick the type of key to create. defaults toecdsa(as it should, honestly).-I,--import PATHβ import an existing key intossh-tpm-agent.--parent-handle HIERARCHYβ the parent for the TPM key. can be a hierarchy or a persistent handle. available hierarchies:owner,o(default)endorsement,enull,nplatform,p
--print-pubkey PATHβ print the public key, given a TPM private key.--supportedβ list the key types your TPM actually supports (vibe check for your hardware π₯).--hierarchy HIERARCHYβ create a public key. β οΈ can only be used with-A.- see Hierarchy Keys in
ssh-tpm-agent(1)for usage. - available hierarchies:
owner,oendorsement,enull,nplatform,p
- see Hierarchy Keys in
--wrap PATHβ an SSH key to wrap for import on a remote machine.--wrap-with PATHβ the parent key to wrap that SSH key with.
π§ EXAMPLES π§
π Key creation
create a key with ssh-tpm-keygen. iconic, effortless, slay:
$ ssh-tpm-keygen
Generating a sealed public/private ecdsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_ecdsa.tpm
Your public key has been saved in /home/user/.ssh/id_ecdsa.pub
The key fingerprint is:
SHA256:NCMJJ2La+q5tGcngQUQvEOJP3gPH8bMP98wJOEMV564
The key's randomart image is the color of television, tuned to a dead channel.
$ cat /home/user/.ssh/id_ecdsa.pub
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOTOsMXyjTc1wiQSKhRiNhKFsHJNLzLk2r4foXPLQYKR0tuXIBMTQuMmc7OiTgNMvIjMrcb9adgGdT3s+GkNi1g=
ok but "the color of television, tuned to a dead channel" for the randomart?? that's art, actually π¨πΊ
πΈ Import existing key
this one is so useful if you wanna back up the key to a remote secure storage while using the key day-to-day from the TPM. best of both worlds, fr fr.
create a key, or use an existing one:
$ ssh-keygen -t ecdsa -f id_ecdsa
Generating public/private ecdsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_ecdsa
Your public key has been saved in id_ecdsa.pub
The key fingerprint is:
SHA256:bDn2EpX6XRX5ADXQSuTq+uUyia/eV3Z6MW+UtxjnXvU user@localhost
The key's randomart image is:
+---[ECDSA 256]---+
| .+=o..|
| o. oo.|
| o... .o|
| . + .. ..|
| S . . o|
| o * . oo=*|
| ..+.oo=+E|
| .++o...o=|
| .++++. .+ |
+----[SHA256]-----+
then import the key using the --import switch:
$ ssh-tpm-keygen --import id_ecdsa
Sealing an existing public/private ecdsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_ecdsa.tpm
The key fingerprint is:
SHA256:bDn2EpX6XRX5ADXQSuTq+uUyia/eV3Z6MW+UtxjnXvU
The key's randomart image is the color of television, tuned to a dead channel.
see? sealed. immaculate. π«Ά
π Create and Wrap private key for client machine on remote srver
(no i'm not fixing the typo, it's part of the lore now π)
on the client side, create a primary key under a hierarchy. this example uses the owner hierarchy with an SRK.
the output file srk.pem needs to be transferred to the remote end β the one that creates the key. this could be done as part of client provisioning.
$ tpm2_createprimary -C o -G ecc -g sha256 -c prim.ctx -a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|noda' -f pem -o srk.pem
on the remote end we create a p256 ssh key, with no password, and wrap it with ssh-tpm-keygen using the srk.pem from the client side.
$ ssh-keygen -t ecdsa -b 256 -N "" -f ./ecdsa.key
OR with openssl:
$ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:prime256v1 -out ecdsa.key
wrap it with ssh-tpm-keygen:
$ ssh-tpm-keygen --wrap-with srk.pub --wrap ecdsa.key -f wrapped_id_ecdsa
on the client side we can unwrap wrapped_id_ecdsa into a loadable key:
$ ssh-tpm-keygen --import ./wrapped_id_ecdsa.tpm --output id_ecdsa.tpm
$ ssh-tpm-add id_ecdsa.tpm
and that's the whole round trip. chef's kiss π₯
π FILES π
~/ssh/id_rsa.tpm,~/ssh/id_ecdsa.tpmβ contains the ssh private keys used byssh-tpm-agent. they are TPM 2.0 TSS key files and are securely wrapped by the TPM. technically they can be shared publicly since they can only ever be used by the TPM they were created on β but honestly? it's probably better to not do that. π~/ssh/id_rsa.pub,~/ssh/id_ecdsa.pubβ contains the ssh public keys. these ones can be shared publicly, and they're in the exact same format as the ones created byssh-keygen(1). share away bestie π
π₯ SEE ALSO π₯
ssh-agent(1), ssh(1), ssh-tpm-keygen(1), ssh-keygen(1)
β NOTES, STANDARDS AND OTHER β
ASN.1 Specification for TPM 2.0 Key Files <https://www.hansenpartnership.com/draft-bottomley-tpm2-keys.html>
aaaand that's the page π
this little gem is ssh-tpm-agent v0.9.0, dated 2026-08-10 β go forth and wrap some keys, bestie, you've got this π¦π
π¦ where this page comes from
- arch rolling: ssh-tpm-agent 0.9.0-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms