Skip to content

Commit fc2cc18

Browse files
committed
Add OpenSC smart card support for SSH agent
1 parent a7dad30 commit fc2cc18

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ssh/setup_agent.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ echo "Adding new identities."
2727
# Otherwise the server you connect to can use the SSH keys
2828
# as if it was your local machine!
2929

30+
# Support for TPM-based keys
3031
LIBTPM2_PKCS11="/usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1"
3132
if [ -f "${LIBTPM2_PKCS11}" ]; then
3233
set +e
@@ -39,6 +40,15 @@ if [ -f "${HOME}/.ssh/id_rsa" ]; then
3940
ssh-add "${HOME}/.ssh/id_rsa"
4041
fi
4142

43+
# Support for smart cards. These may require a PIN, which is why this is after id_rsa.
44+
# https://www.linux.fi/wiki/HST#Ssh_2
45+
OPENSC_PKCS11="/usr/lib/x86_64-linux-gnu/opensc-pkcs11.so"
46+
if [ -f "${OPENSC_PKCS11}" ]; then
47+
set +e
48+
ssh-add -s "${OPENSC_PKCS11}"
49+
set -e
50+
fi
51+
4252
. "${CONF_SCRIPT}"
4353

4454
echo "Configured identities:"

0 commit comments

Comments
 (0)