change output
This commit is contained in:
parent
deab93a3dc
commit
866a059ad1
2 changed files with 13 additions and 15 deletions
|
@ -115,7 +115,7 @@ ssh-runinagent () {
|
||||||
shift
|
shift
|
||||||
sshcommand=${@}
|
sshcommand=${@}
|
||||||
|
|
||||||
logdebug "run command »$sshcommand« in agent $agentfile" >&2
|
logtrace "run command »$sshcommand« in agent $agentfile" >&2
|
||||||
if [ -e "$agentfile" ]; then
|
if [ -e "$agentfile" ]; then
|
||||||
/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand"
|
/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand"
|
||||||
return $?
|
return $?
|
||||||
|
|
26
functions.sh
26
functions.sh
|
@ -683,7 +683,6 @@ utoken () {
|
||||||
token () {
|
token () {
|
||||||
|
|
||||||
[ -z "${SSH_ADD_OPTIONS+x}" ] && { SSH_ADD_OPTIONS=${SSH_ADD_DEFAULT_OPTIONS}; export SSH_ADD_OPTIONS; }
|
[ -z "${SSH_ADD_OPTIONS+x}" ] && { SSH_ADD_OPTIONS=${SSH_ADD_DEFAULT_OPTIONS}; export SSH_ADD_OPTIONS; }
|
||||||
echo [ -z "${SSH_IDENTITIES_DIR+x}" ]
|
|
||||||
[ -z "${SSH_IDENTITIES_DIR+x}" ] && { SSH_IDENTITIES_DIR=${SSH_IDENTITIES_DEFAULT_DIR-${HOME}/.ssh/identities}; export SSH_IDENTITIES_DIR; }
|
[ -z "${SSH_IDENTITIES_DIR+x}" ] && { SSH_IDENTITIES_DIR=${SSH_IDENTITIES_DEFAULT_DIR-${HOME}/.ssh/identities}; export SSH_IDENTITIES_DIR; }
|
||||||
local FORCE
|
local FORCE
|
||||||
local ssh_identity
|
local ssh_identity
|
||||||
|
@ -698,10 +697,10 @@ token () {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
identitydir=${SSH_IDENTITIES_DIR}/${ssh_identity}
|
identitydir=${SSH_IDENTITIES_DIR}/${ssh_identity}
|
||||||
echo identitydir: $identitydir
|
logtrace "identitydir: $identitydir"
|
||||||
[ -e "${identitydir}/config" ] && echo found "${identitydir}/config"
|
[ -e "${identitydir}/config" ] && echo found "${identitydir}/config"
|
||||||
[ -e "${identitydir}/config" ] && eval $(<"${identitydir}/config")
|
[ -e "${identitydir}/config" ] && eval $(<"${identitydir}/config")
|
||||||
echo SSH_ADD_OPTIONS: $SSH_ADD_OPTIONS
|
logtrace "SSH_ADD_OPTIONS: $SSH_ADD_OPTIONS"
|
||||||
local fingerprints
|
local fingerprints
|
||||||
declare -a fingerprints
|
declare -a fingerprints
|
||||||
local tokenfingerprint
|
local tokenfingerprint
|
||||||
|
@ -714,19 +713,18 @@ token () {
|
||||||
fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
|
fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
|
||||||
tokenfingerprint="$(ssh-keygen -l -D $PKCS11_MODULE|tr -s ' '|awk '{print $2}')"
|
tokenfingerprint="$(ssh-keygen -l -D $PKCS11_MODULE|tr -s ' '|awk '{print $2}')"
|
||||||
|
|
||||||
echo fingerprints ${fingerprints[*]}
|
logdebug "fingerprints ${fingerprints[*]}"
|
||||||
echo -n "${tokenfingerprint}: "
|
|
||||||
if [[ ${fingerprints[*]} =~ $tokenfingerprint ]]; then
|
if [[ ${fingerprints[*]} =~ $tokenfingerprint ]]; then
|
||||||
echo "loaded"
|
logdebug "${tokenfingerprint}: loaded"
|
||||||
if $FORCE; then
|
if $FORCE; then
|
||||||
echo "remove token and readd it again" >&2
|
logdebug "remove token and readd it again" >&2
|
||||||
ssh-runinagent $agentfile ssh-add -e $PKCS11_MODULE
|
logdebug "$(ssh-runinagent $agentfile ssh-add -e $PKCS11_MODULE)"
|
||||||
ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s $PKCS11_MODULE
|
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s $PKCS11_MODULE)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "not loaded"
|
logdebug "${tokenfingerprint}: not loaded"
|
||||||
$FORCE && ssh-runinagent $agentfile ssh-add -e $PKCS11_MODULE
|
$FORCE && logdebug "$(ssh-runinagent $agentfile ssh-add -e $PKCS11_MODULE)"
|
||||||
ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s $PKCS11_MODULE
|
loginfo "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s $PKCS11_MODULE)"
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -785,12 +783,12 @@ ssh-runinagent () {
|
||||||
shift
|
shift
|
||||||
sshcommand=${@}
|
sshcommand=${@}
|
||||||
|
|
||||||
echo "run command »$sshcommand« in agent $agentfile" >&2
|
logtrace "run command »$sshcommand« in agent $agentfile" >&2
|
||||||
if [ -e "$agentfile" ]; then
|
if [ -e "$agentfile" ]; then
|
||||||
/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand"
|
/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID; . $agentfile >/dev/null 2>/dev/null; $sshcommand"
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
echo "agentfile not existent" >&2
|
logwarn "agentfile not existent" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue