Skip to content
KitploitKITPLOIT
FerramentasBlog
Enviar
FerramentasBlog
Enviar

Ferramentas de Hacking, PenTest e Cibersegurança para o seu Arsenal de Segurança!

Kitploit é um diretório de ferramentas de hacking, cibersegurança e pentesting. Descubra as últimas atualizações de projetos para encontrar vulnerabilidades, analisar sistemas, automatizar testes e fortalecer sua segurança.

··Feeds·Contato·Privacidade·© 2026 Kitploit

Diretório de Ferramentas

Categorias

Ver todas as categorias
Loading categories
ssh-tpm-agent — Agente SSH que cria e gere chaves seladas por TPM para autenticação vinculada ao hardware, suportando geração de chaves, importação, encapsulamento, proteção por PIN e fallback de proxy. | Kitploit
Ferramentas/GitHubGitHub/foxboron/ssh-tpm-agent
Ferramentas de Criptografia/DescriptografiaSegurança na NuvemDevSecOpsSegurança de HardwareGerenciamento de Identidade e Acesso (IAM)Autenticação
GitHubfoxboron/ssh-tpm-agent

ssh-tpm-agent

Agente SSH que cria e gere chaves seladas por TPM para autenticação vinculada ao hardware, suportando geração de chaves, importação, encapsulamento, proteção por PIN e fallback de proxy.

Ver Repositório
74339há 17 diasRevisado pelo Kitploit

Mais Populares

Ver todos →

Descubra as ferramentas mais usadas pela nossa comunidade.

Explore todas as ferramentas

Navegue pela nossa coleção de ferramentas

Ver todas as ferramentas →
Compartilhar

SSH agent para TPM

ssh-tpm-agent é um agente compatível com ssh-agent que permite que chaves sejam criadas pelo Trusted Platform Module (TPM) para autenticação em servidores ssh.

Chaves seladas pelo TPM são chaves privadas criadas dentro do Trusted Platform Module (TPM) e seladas em arquivos com sufixo .tpm. Elas estão vinculadas ao hardware onde são produzidas e não podem ser transferidas para outras máquinas.

Isso permite que você utilize um cliente nativo em vez de precisar carregar bibliotecas PKCS11 existentes no ssh-agent e/ou no cliente ssh.

O projeto utiliza TPM 2.0 Key Files implementados através do projeto go-tpm-keyfiles.

Funcionalidades

  • Um ssh-agent funcional.
  • Criação de chaves ssh protegidas no TPM.
  • Criação de chaves SSH encapsuladas remotamente para importação.
  • Suporte a PIN, proteção contra ataque de dicionário do TPM permite usar PINs de baixa entropia em vez de senhas.
  • Criptografia de sessão TPM.
  • Suporte a proxy para outros servidores ssh-agent para fallback.

Suporte a SWTPM

Em vez de utilizar o TPM diretamente, você pode usar --swtpm ou export SSH_TPM_AGENT_SWTPM=1 para criar uma identidade baseada em swtpm que será armazenada em /var/tmp/ssh-tpm-agent.

Observe que o swtpm não oferece propriedades de segurança e deve ser usado apenas para testes.

Instalação

A maneira mais simples de instalar este plugin é executando o seguinte:

root@kitploit:~
go install github.com/foxboron/ssh-tpm-agent/cmd/...@latest

Alternativamente, baixe os binários pré-compilados.

Uso

root@kitploit:~
# Criar chave
$ ssh-tpm-keygen
Generating a sealed public/private ecdsa key pair.
Enter file in which to save the key (/home/fox/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/fox/.ssh/id_ecdsa.tpm
Your public key has been saved in /home/fox/.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/fox/.ssh/id_ecdsa.pub
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOTOsMXyjTc1wiQSKhRiNhKFsHJNLzLk2r4foXPLQYKR0tuXIBMTQuMmc7OiTgNMvIjMrcb9adgGdT3s+GkNi1g=

# Usando o socket
$ ssh-tpm-agent -l /var/tmp/tpm.sock

$ export SSH_AUTH_SOCK="$(ssh-tpm-agent --print-socket)"

$ ssh [email protected]

Nota: Para o ssh-tpm-agent, você pode especificar a senha do proprietário do TPM usando as flags de linha de comando -o ou --owner-password, que são preferíveis. Alternativamente, você pode usar a variável de ambiente SSH_TPM_AGENT_OWNER_PASSWORD.

Importar chave existente

Útil se quiser fazer backup da chave para um armazenamento remoto seguro enquanto usa a chave no dia a dia a partir do TPM.

root@kitploit:~
# Criar uma chave ou usar uma existente
$ 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 fox@framework
The key's randomart image is:
+---[ECDSA 256]---+
|           .+=o..|
|           o. oo.|
|          o... .o|
|       . + ..  ..|
|        S .   . o|
|       o * . oo=*|
|        ..+.oo=+E|
|        .++o...o=|
|       .++++. .+ |
+----[SHA256]-----+

# Importar a chave
$ 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.

Instalar serviço de usuário

Serviços ativados por socket permitem que você inicie o ssh-tpm-agent quando necessário pelo seu sistema.

root@kitploit:~
# Usando o socket
$ ssh-tpm-agent --install-user-units
Installed /home/fox/.config/systemd/user/ssh-tpm-agent.socket
Installed /home/fox/.config/systemd/user/ssh-tpm-agent.service
Enable with: systemctl --user enable --now ssh-tpm-agent.socket

$ systemctl --user enable --now ssh-tpm-agent.socket

$ export SSH_AUTH_SOCK="$(ssh-tpm-agent --print-socket)"

$ ssh [email protected]

Suporte a proxy

root@kitploit:~
# Iniciar o ssh-agent usual
$ eval $(ssh-agent)

# Criar uma chave RSA forte
$ ssh-keygen -t rsa -b 4096 -f id_rsa -C ssh-agent
...
The key fingerprint is:
SHA256:zLSeyU/6NKHGEvyZLA866S1jGqwdwdAxRFff8Z2N1i0 ssh-agent

$ ssh-add id_rsa
Identity added: id_rsa (ssh-agent)

# Imprimir chave longa
$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc[...]8TWynQ== ssh-agent

# Criar chave no TPM
$ ssh-tpm-keygen -C ssh-tpm-agent
Generating a sealed public/private ecdsa key pair.
Enter file in which to save the key (/home/fox/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Confirm passphrase:
Your identification has been saved in /home/fox/.ssh/id_ecdsa.tpm
Your public key has been saved in /home/fox/.ssh/id_ecdsa.pub
The key fingerprint is:
SHA256:PoQyuzOpEBLqT+xtP0dnvyBVL6UQTiQeCWN/EXIxPOo
The key's randomart image is the color of television, tuned to a dead channel.

# Iniciar ssh-tpm-agent com um socket proxy
$ ssh-tpm-agent -A "${SSH_AUTH_SOCK}" &

$ export SSH_AUTH_SOCK="$(ssh-tpm-agent --print-socket)"

# ssh-tpm-agent está fazendo proxy das chaves do ssh-agent
$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc[...]8TWynQ== ssh-agent
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo[...]q4whro= ssh-tpm-agent

ssh-tpm-add

root@kitploit:~
$ ssh-tpm-agent --no-load &
2023/08/12 13:40:50 Listening on /run/user/1000/ssh-tpm-agent.sock

$ export SSH_AUTH_SOCK="$(ssh-tpm-agent --print-socket)"

$ ssh-add -L
The agent has no identities.

$ ssh-tpm-add $HOME/.ssh/id_ecdsa.tpm
Identity added: /home/user/.ssh/id_ecdsa.tpm

$ ssh-add -L
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJCxqisGa9IUNh4Ik3kwihrDouxP7S5Oun2hnzTvFwktszaibJruKLJMxHqVYnNwKD9DegCNwUN1qXCI/UOwaSY= test

Criar e encapsular chave privada para máquina cliente em servidor remoto

Do lado do cliente, crie uma chave primária sob uma hierarquia. Este exemplo usará a hierarquia do proprietário com um SRK.

O arquivo de saída srk.pem precisa ser transferido para o lado remoto que cria a chave. Isso pode ser feito como parte do provisionamento do cliente.

root@kitploit:~
$ tpm2_createprimary -C o -G ecc -g sha256 -c prim.ctx -a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|noda' -f pem -o srk.pem

No lado remoto, criamos uma chave ssh p256, sem senha, e a encapsulamos com ssh-tpm-keygen usando o srk.pem do lado do cliente.

root@kitploit:~
$ ssh-keygen -t ecdsa -b 256 -N "" -f ./ecdsa.key
# OU com openssl
$ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:prime256v1 -out ecdsa.key

# Encapsular com ssh-tpm-keygen
$ ssh-tpm-keygen --wrap-with srk.pub --wrap ecdsa.key -f wrapped_id_ecdsa

No lado do cliente, podemos desencapsular wrapped_id_ecdsa para uma chave carregável.

root@kitploit:~
$ ssh-tpm-keygen --import ./wrapped_id_ecdsa.tpm -f id_ecdsa.tpm
$ ssh-tpm-add id_ecdsa.tpm

ssh-tpm-hostkey

ssh-tpm-agent também suporta armazenar chaves de host dentro do TPM.

root@kitploit:~
$ sudo ssh-tpm-keygen -A
2023/09/03 17:03:08 INFO Generating new ECDSA host key
2023/09/03 17:03:08 INFO Wrote /etc/ssh/ssh_tpm_host_ecdsa_key.tpm
2023/09/03 17:03:08 INFO Generating new RSA host key
2023/09/03 17:03:15 INFO Wrote /etc/ssh/ssh_tpm_host_rsa_key.tpm

$ sudo ssh-tpm-hostkeys --install-system-units
Installed /usr/lib/systemd/system/ssh-tpm-agent.service
Installed /usr/lib/systemd/system/ssh-tpm-agent.socket
Installed /usr/lib/systemd/system/ssh-tpm-genkeys.service
Enable with: systemctl enable --now ssh-tpm-agent.socket

$ sudo ssh-tpm-hostkeys --install-sshd-config
Installed /etc/ssh/sshd_config.d/10-ssh-tpm-agent.conf
Restart sshd: systemd restart sshd

$ systemctl enable --now ssh-tpm-agent.socket
$ systemd restart sshd

$ sudo ssh-tpm-hostkeys
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCLDH2xMDIGb26Q3Fa/kZDuPvzLzfAH6CkNs0wlaY2AaiZT2qJkWI05lMDm+mf+wmDhhgQlkJAHmyqgzYNwqWY0= root@framework
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAoMPsv5tEpTDFw34ltkF45dTHAPl4aLu6HigBkNnIzsuWqJxhjN6JK3vaV3eXBzy8/UJxo/R0Ml9/DRzFK8cccdIRT1KQtg8xIikRReZ0usdeqTC+wLpW/KQqgBLZ1PphRINxABWReqlnbtPVBfj6wKlCVNLEuTfzi1oAMj3KXOBDcTTB2UBLcwvTFg6YnbTjrpxY83Y+3QIZNPwYqd7r6k+e/ncUl4zgCvvxhoojGxEM3pjQIaZ0Him0yT6OGmCGFa7XIRKxwBSv9HtyHf5psgI+X5A2NV2JW2xeLhV2K1+UXmKW4aXjBWKSO08lPSWZ6/5jQTGN1Jg3fLQKSe7f root@framework

$ ssh-keyscan -t ecdsa localhost
# localhost:22 SSH-2.0-OpenSSH_9.4
localhost ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCLDH2xMDIGb26Q3Fa/kZDuPvzLzfAH6CkNs0wlaY2AaiZT2qJkWI05lMDm+mf+wmDhhgQlkJAHmyqgzYNwqWY0=

ssh-config

É possível usar as chaves públicas criadas por ssh-tpm-keygen em configurações ssh.

O exemplo abaixo usa ssh-tpm-agent e também passa a chave pública para garantir que nem todas as identidades sejam vazadas do agente.

root@kitploit:~
Host example.com
    IdentityAgent $SSH_AUTH_SOCK

Host *
    IdentityAgent /run/user/1000/ssh-tpm-agent.sock
    IdentityFile ~/.ssh/id_ecdsa.pub

Licença

Licenciado sob a licença MIT. Veja LICENSE ou https://opensource.org/licenses/MIT

Baixar ferramenta