Hacker News 中文摘要

RSS订阅

macOS原生安全飞地支持的SSH密钥 -- Native Secure Enclave backed SSH keys on macOS

文章摘要

MacOS Tahoe系统可通过内置安全芯片生成SSH密钥,替代第三方工具。系统库ssh-keychain.dylib新增SecurityKeyProvider接口,可直接调用安全芯片功能,类似FIDO2设备交互方式。用户可通过sc_auth命令创建需生物识别的密钥,并查看已创建密钥。

文章总结

MacOS原生支持基于安全隔离区(Secure Enclave)的SSH密钥管理

最新发现表明,MacOS Tahoe系统能够生成和使用基于安全隔离区的SSH密钥,这可以替代Secretive等第三方工具。系统通过/usr/lib/ssh-keychain.dylib共享库实现该功能,该库不仅支持传统的智能卡接口(PKCS11Provider),近期还新增了直接调用安全隔离区的SecurityKeyProvider接口。

密钥创建与管理

通过sc_auth命令可创建需生物识别的安全隔离区密钥: sc_auth create-ctk-identity -l ssh -k p-256-ne -t bio 创建后可通过list-ctk-identities查看密钥指纹,或使用delete-ctk-identity删除指定密钥。

SSH应用实践

  1. 密钥导出: ssh-keygen -w /usr/lib/ssh-keychain.dylib -K -N "" 注意:系统会要求输入PIN(直接回车跳过),生成的"私钥"实际仅为凭证引用。

  2. 直接连接: ssh -o SecurityKeyProvider=/usr/lib/ssh-keychain.dylib 目标主机

  3. ssh-agent集成: ssh-add -K -S /usr/lib/ssh-keychain.dylib

全局配置建议

.zprofile中添加: export SSH_SK_PROVIDER=/usr/lib/ssh-keychain.dylib 此后可直接使用ssh-add -K和常规ssh命令。

可导出密钥方案

支持创建加密备份的密钥变体: sc_auth create-ctk-identity -l ssh-exportable -k p-256 -t bio sc_auth export-ctk-identity -h [指纹] -f 导出文件.pem 其他设备可通过import-ctk-identities命令导入密钥。

(注:原文中的视频引用和部分重复性命令行示例已作精简,保留核心操作流程和关键说明)

评论总结

以下是评论内容的总结:

  1. 对Mac加密体验的批评

    • 观点:Mac上使用加密密钥(如GPG或SSH)的过程繁琐,可能导致用户选择明文存储。
    • 引用:
      • "It's a total pain in the ass to try to have password encrypted gpg or ssh keys in mac."
      • "Nothing better that another way to make it even more painful and complicated."
  2. 对Secretive工具的积极评价

    • 观点:Secretive提供了比物理密钥更便捷的SSH管理,但存在一些技术问题。
    • 引用:
      • "I've been using Secretive for years, and prefer it to all the physical key/card based systems."
      • "However the Tahoe version of secretive is buggy and frequently locks up."
  3. 对新技术(如Secure Enclave)的兴趣

    • 观点:用户对新功能表示兴趣,但部分人暂时不会放弃现有工具(如Yubikeys)。
    • 引用:
      • "Won't be ditching Yubikeys just yet but I can see a number of use-cases for this already."
      • "Oh, this is neat! I wonder if apple just added support for the secure enclave."
  4. 对密钥备份和安全性的担忧

    • 观点:Secure Enclave中的密钥不可备份,可能带来数据丢失风险。
    • 引用:
      • "If you lose your laptop, you also lose the key?"
      • "Probably not the worst thing, but still feels like a hole."
  5. 对简化工具的欢迎

    • 观点:用户赞赏新技术减少了第三方工具的依赖。
    • 引用:
      • "This is just so perfect. No longer a 3rd party glue and separate ssh agent is needed."
      • "Secretive is a bit friendlier to set up but I'll probably switch to this anyway."
  6. 对功能扩展的期待

    • 观点:用户希望看到类似功能扩展到其他领域(如GPG签名)。
    • 引用:
      • "Does anybody know if there is something similar for gpg keys?"
      • "Time to up my game and finish adding new features to KeyMux."