Skip to content

Instantly share code, notes, and snippets.

View Wesseldr's full-sized avatar

WesdR Wesseldr

  • CRESCE b.v.
  • Europe
  • 21:57 (UTC +02:00)
  • X @CRESCE
View GitHub Profile
@Wesseldr
Wesseldr / .bash_profile
Last active February 3, 2018 22:12
Share ssh-agent between all terminals
# Add this to your .profile or .bash_profile, Tested on OsX 10.12, untested on Debian & Linux.
# Share ssh-agent between new shells and not start a new agent every new shell is opend.
# Warning! this can be a security risk for evil scripts
if [ -z "$SSH_AUTH_SOCK" ]; then
if ! pgrep -xu $(id -u) ssh-agent > /dev/null; then
ssh-agent | grep -v ^echo > ~/.ssh-agent.sh
fi
. ~/.ssh-agent.sh
fi
@Wesseldr
Wesseldr / .bash_profile
Last active February 3, 2018 22:14
PKCS#11 and ssh-agent, ask smartcard (YubiKey) pin code if not yet added, else do not add smart card again to ssh-agent
# Add this to your .profile or .bash_profile, Tested on OsX 10.12, untested on Debian & Linux.
# Check if OpenSC smartcard is already added to an empty ssh-agent than add smart card, else skip this
ssh-add -L | grep "The agent has no identities" > /dev/null
if [ $? -eq 0 ]; then
ssh-add -s /usr/local/lib/opensc-pkcs11.so
fi