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
- The smart card contains your certificate and private key.
- The card is inserted in the reader and connected to the computer.
The
pcscdservice is running on your local machine.For details, see Installing tools for managing and using smart cards.
Procedure
Create a new directory for SSH keys in the home directory of the user who uses smart card authentication:
# mkdir /home/<example_user>/.sshRun the
ssh-keygen -Dcommand with theopensclibrary to retrieve the existing public key paired with the private key on the smart card, and add it to theauthorized_keyslist 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_keysSSH requires access right configuration for the
/.sshdirectory and theauthorized_keysfile. 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
Display the keys:
# cat ~<example_user>/.ssh/authorized_keysThe 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.