Skip to content

本文为 SPIRE 官方文档 plugin_server_nodeattestor_sshpop.md 的中文译本,以英文原文为准。 🔗 穿越源码分析:Server 详解 · NodeAttestor

Server 插件:NodeAttestor "sshpop"

必须与 Agent 侧 sshpop 插件配合使用

sshpop 插件用于对那些通过带外(out-of-band)机制预置了 SSH 身份的节点进行认证。它会验证证书是否根植于一组受信任的 CA,并向 agent 插件发起一次基于签名的持有性证明(proof-of-possession,PoP)挑战,以验证该节点确实持有对应的私钥。

插件生成的 SPIFFE ID 基于证书指纹(certificate fingerprint),该指纹是对 openssh 格式证书的 sha256 哈希进行无填充(unpadded)、URL 安全的 base64 编码后得到的。

xml
spiffe://<trust_domain>/spire/agent/sshpop/<fingerprint>
ConfigurationDescriptionDefault
cert_authorities一组以 ssh authorized_keys 格式表示的受信任 CA。
cert_authorities_path一个文件,其中包含以 ssh authorized_keys 格式表示的受信任 CA 列表。
canonical_domain用于将主机名与证书的有效主体(valid principals)进行校验的域名后缀。参见 ssh_config(5) 中的 CanonicalDomains。
agent_path_templateAgent SPIFFE ID 的 URL 路径部分格式,以 text/template 格式描述。"{{ .PluginName}}/{{ .Fingerprint }}"

如果同时配置了 cert_authoritiescert_authorities_path,则最终的授权密钥集合是二者的并集。

Example Config(示例配置)

agent.conf

hcl
    NodeAttestor "sshpop" {
        plugin_data {
            host_cert_path = "./conf/agent/dummy_agent_ssh_key-cert.pub"
            host_key_path = "./conf/agent/dummy_agent_ssh_key"
        }
    }

server.conf

hcl
    NodeAttestor "sshpop" {
        plugin_data {
            cert_authorities = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEAWPAsKJ/qMYUIBeH7BLMRCE/bkUvMHX+7OZhANk45S"]
            cert_authorities_path = "./conf/server/dummy_ssh_cert_authority.pub"
            
            # 合理地校验证书 principals 中设置的 FQDN。
            # canonical_domain = "example.com"

            # 修改 agent 的 SPIFFE ID 格式
            # agent_path_template = "static/{{ index .ValidPrincipals 0 }}"
        }
    }