add debug, fix minor things
This commit is contained in:
parent
8f7759285e
commit
511f18a8dd
1 changed files with 31 additions and 6 deletions
37
functions.sh
37
functions.sh
|
@ -72,13 +72,28 @@ _pkcs11module_hook() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _remote_ssh_agent_hook () {
|
||||||
|
|
||||||
|
if [ -e ~/.ssh/ssh_from_remote_auth_sock ]
|
||||||
|
then
|
||||||
|
logdebug "remote ssh-agent-socket exists"
|
||||||
|
SSH_AUTH_SOCK_REMOTE=~/.ssh/ssh_from_remote_auth_sock
|
||||||
|
source ~/.ssh/p11m
|
||||||
|
else
|
||||||
|
logdebug "remote ssh-agent-socket does not exists"
|
||||||
|
unset SSH_AUTH_SOCK_REMOTE
|
||||||
|
unset P11M
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _tmux_hook() {
|
function _tmux_hook() {
|
||||||
|
|
||||||
## this function updates in combination with PROMPT_COMMAND the shell-environment-variables in tmux-sessions,
|
## this function updates in combination with PROMPT_COMMAND the shell-environment-variables in tmux-sessions,
|
||||||
# every time prompt is called. It does it only, when called from tmux (Environment TMUX is set)
|
# every time prompt is called. It does it only, when called from tmux (Environment TMUX is set)
|
||||||
# [ -z "${TMUX+x}" ] || eval "$(tmux show-environment -s)"
|
# [ -z "${TMUX+x}" ] || eval "$(tmux show-environment -s)"
|
||||||
|
|
||||||
if [ -n "${TMUX}" ]; then
|
if [ -n "${TMUX:-}" ]; then
|
||||||
eval "$(tmux show-environment -s)"
|
eval "$(tmux show-environment -s)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -871,6 +886,7 @@ utoken () {
|
||||||
|
|
||||||
[ -z "${PKCS11_MODULE+x}" ] && { PKCS11_MODULE=$P11M; export PKCS11_MODULE; }
|
[ -z "${PKCS11_MODULE+x}" ] && { PKCS11_MODULE=$P11M; export PKCS11_MODULE; }
|
||||||
|
|
||||||
|
logdebug "PKCS11_MODULE=${PKCS11_MODULE:-undefined}"
|
||||||
if [ -n "${ssh_identity+x}" ]; then
|
if [ -n "${ssh_identity+x}" ]; then
|
||||||
agentfile="${HOME}/.ssh/agents/agent-${ssh_identity}-$(hostname)"
|
agentfile="${HOME}/.ssh/agents/agent-${ssh_identity}-$(hostname)"
|
||||||
if [ -e "$agentfile" ]; then
|
if [ -e "$agentfile" ]; then
|
||||||
|
@ -884,7 +900,9 @@ utoken () {
|
||||||
|
|
||||||
token(){
|
token(){
|
||||||
|
|
||||||
[ -z "${PKCS11_MODULE+x}" ] && { PKCS11_MODULE=$P11M; export PKCS11_MODULE; }
|
[ -z "${PKCS11_MODULE:+x}" -a -n "{P11M:-x}" ] && { PKCS11_MODULE=$P11M; export PKCS11_MODULE; }
|
||||||
|
loginfo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK:-unset}"
|
||||||
|
loginfo "PKCS11_MODULE=${PKCS11_MODULE:-unset}"
|
||||||
|
|
||||||
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
|
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
|
||||||
# So remember and unset DISPLAY, and set it at the end again, if it was set before
|
# So remember and unset DISPLAY, and set it at the end again, if it was set before
|
||||||
|
@ -899,7 +917,7 @@ token(){
|
||||||
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token.
|
# Check if public-keys in tmppubkey are working. They are not working, if you removed and add back hardware-token.
|
||||||
loginfo "$(ssh-add -T ${tmppubkey}|| { ssh-add -e $PKCS11_MODULE; ssh-add -s $PKCS11_MODULE; } )"
|
loginfo "$(ssh-add -T ${tmppubkey}|| { ssh-add -e $PKCS11_MODULE; ssh-add -s $PKCS11_MODULE; } )"
|
||||||
logdebug "$(rm "${tmppubkey}")"
|
logdebug "$(rm "${tmppubkey}")"
|
||||||
logdebug "$(ssh-add -l )"
|
loginfo "$(ssh-add -l )"
|
||||||
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
|
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
|
||||||
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG
|
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG
|
||||||
|
|
||||||
|
@ -935,15 +953,22 @@ token-list-objects() {
|
||||||
loadagent() {
|
loadagent() {
|
||||||
ENTRY
|
ENTRY
|
||||||
local af
|
local af
|
||||||
af=$(startagent --create-only $1 )
|
af=$(sshstartagent --create-only $1 )
|
||||||
loginfo "Load agent from $af"
|
loginfo "Load agent from $af"
|
||||||
unset SSH_AUTH_SOCKET SSH_AGENT_PID PKCS11_MODULE
|
unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE
|
||||||
[ -n "${af+x}" ] && eval $(<$af)
|
[ -n "${af+x}" ] && eval $(<$af)
|
||||||
|
if which tmux 1>/dev/null 2>&1
|
||||||
|
then
|
||||||
|
[ -n "${SSH_AUTH_SOCK:-}" ] && tmux set-environment SSH_AUTH_SOCK $SSH_AUTH_SOCK
|
||||||
|
[ -n "${SSH_AGENT_PID:-}" ] && tmux set-environment SSH_AGENT_PID $SSH_AGENT_PID
|
||||||
|
[ -n "${PKCS11_MODULE:-}" ] && tmux set-environment PKCS11_MODULE $PKCS11_MODULE
|
||||||
|
fi
|
||||||
logdebug "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK-not set}"
|
logdebug "SSH_AUTH_SOCK: ${SSH_AUTH_SOCK-not set}"
|
||||||
logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID-not set}"
|
logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID-not set}"
|
||||||
|
logdebug "PCKS11_MODULE: ${PCKS11_MODULE-not set}"
|
||||||
loginfo "currently loaded keys in agent:
|
loginfo "currently loaded keys in agent:
|
||||||
$(ssh-add -l)"
|
$(ssh-add -l)"
|
||||||
export P11M=$PKCS11_MODULE
|
# export P11M=$PKCS11_MODULE
|
||||||
|
|
||||||
EXIT
|
EXIT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue