Как исправить Ubuntu open /usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1: No such file or directory

Проблема

В Ubuntu 26.04 или новее при попытке подключения к SSH-хосту с использованием SSH-ключа на базе TPM возникает следующая ошибка:

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-провайдера на новый.

Например, измените это:

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.so

Check out similar posts by category: Linux