add scripts for bmi-usage, and etoken

This commit is contained in:
Jakobus Schürz 2020-07-06 11:40:19 +02:00
parent 600fb25bff
commit 5f7b354032
3 changed files with 58 additions and 0 deletions

23
bin/ssh-init-pkcs11 Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
set -eu
set -x
[ -z "${PKCS11_MODULE+x}" ] && PKCS11_MODULE="$(dnf repoquery --installed -l p11-kit | grep \/p11-kit-proxy.so\$ | head -1)"
echo SSH_AGENT_PID before: $SSH_AGENT_PID
[ -z "$(pidof ssh-agent)" -o "${SSH_AGENT_PID}" != "$(pidof ssh-agent)" ] && eval "$(ssh-agent -s)"
echo SSH_AGENT_PID after: $SSH_AGENT_PID
#if ssh-add -l | grep -q "${PKCS11_MODULE}"; then
# # Remove any stale loaded keys from token, ssh-agent does not automatically
# # reconnect with the token when you reinsert it.
# ssh-add -e "${PKCS11_MODULE}"
#fi
ssh-add -e "${PKCS11_MODULE}" 2>/dev/null
echo $?
# Tell ssh-agent to use the keys on the token
ssh-add -s "${PKCS11_MODULE}"

6
bin/startbmi Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
ssh -fN bmi-pfwd
x2goclient --hide --close-disconnect --session "BMI Thunderbird" &

29
bin/token Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
#set -eu
#set -x
[ -z "${PKCS11_MODULE+x}" ] && { PKCS11_MODULE=/usr/lib64/p11-kit-proxy.so; export PKCS11_MODULE; }
ssh-add -l &>/dev/null
if [ "$?" == 2 ]; then
test -r ~/.ssh-agent && \
eval "$(<~/.ssh-agent)" >/dev/null
ssh-add -l &>/dev/null
if [ "$?" == 2 ]; then
(umask 066; ssh-agent > ~/.ssh-agent)
eval "$(<~/.ssh-agent)" >/dev/null
fi
fi
ssh-add -l &>/dev/null
if [ "$?" == 0 ]; then
# Remove and add again $PKCS11_MODULE
ssh-add -e $PKCS11_MODULE
ssh-add -s $PKCS11_MODULE
else
echo "not able to create ssh-agent"
fi