6.4. Configuring SSH access using smart card authentication


SSH connections require authentication. You can use a password or a certificate. Follow this procedure to enable authentication using a certificate stored on a smart card.

For details about configuring smart cards with authselect, see Configuring smart cards using authselect.

Prerequisites

Procedure

  1. Create a new directory for SSH keys in the home directory of the user who uses smart card authentication:

    # mkdir /home/<example_user>/.ssh
  2. Run the ssh-keygen -D command with the opensc library to retrieve the existing public key paired with the private key on the smart card, and add it to the authorized_keys list of the user’s SSH keys directory to enable SSH access with smart card authentication.

    # ssh-keygen -D /usr/lib64/pkcs11/opensc-pkcs11.so >> ~<example_user>/.ssh/authorized_keys
  3. SSH requires access right configuration for the /.ssh directory and the authorized_keys file. To set or change the access rights, enter:

    # chown -R <example_user:example_user> ~<example_user>/.ssh/
    # chmod 700 ~<example_user>/.ssh/
    # chmod 600 ~<example_user>/.ssh/authorized_keys

Verification

  1. Display the keys:

    # cat ~<example_user>/.ssh/authorized_keys

    The terminal displays the keys.

You can verify the SSH access with the following command:

# ssh -I /usr/lib64/opensc-pkcs11.so -l <example_user> localhost hostname

If the configuration is successful, you are prompted to enter the smart card PIN.

The configuration works now locally. Now you can copy the public key and distribute it to authorized_keys files located on all servers on which you want to use SSH.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部