如何修复 Ubuntu 中 open /usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1: No such file or directory 错误
问题
在 Ubuntu 26.04 或更高版本中,当你想使用基于 TPM 的 SSH 密钥连接到 SSH 主机时,会出现以下错误:
tpm2_pkcs11_error.txt
lib_contains_symbol: open /usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1: No such file or directory
provider /usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1 is not a PKCS11 library
Received disconnect from 100.64.0.132 port 22:2: Too many authentication failures
Disconnected from 10.1.2.3 port 22解决方案
在 Ubuntu 24.04 到 26.04 之间,软件包 libtpm2-pkcs11-1 进行了更新,因此库文件的位置发生了变化,从
old_pkcs11_path.txt
/usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1移动到了
new_pkcs11_path.txt
/usr/lib/x86_64-linux-gnu/pkcs11/libtpm2_pkcs11.so因此,你需要编辑 SSH 配置(通常位于 ~/.ssh/config 或 /etc/ssh/ssh_config),将 PKCS11 provider 库的路径修改为新路径。
例如,将以下配置:
ssh_config_example_old
Host myserver
HostName myserver.mydomain.com
PasswordAuthentication no
PKCS11Provider /usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1修改为:
ssh_config_example
Host myserver
HostName myserver.mydomain.com
PasswordAuthentication no
PKCS11Provider /usr/lib/x86_64-linux-gnu/pkcs11/libtpm2_pkcs11.soCheck out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow