fix some outputs

This commit is contained in:
Jakobus Schürz 2023-08-09 17:39:24 +02:00
parent e8e656f192
commit 1c68ef8be0

View file

@ -69,7 +69,7 @@ ssh_runinagent() {
if [ -e "$agentfile" ]; then if [ -e "$agentfile" ]; then
#/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE; eval $(<$agentfile) >/dev/null 2>&1; echo SSH_AUTH_SOCK ${SSH_AUTH_SOCK:-not set} >&2; $sshcommand" #/bin/sh -c "unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE; eval $(<$agentfile) >/dev/null 2>&1; echo SSH_AUTH_SOCK ${SSH_AUTH_SOCK:-not set} >&2; $sshcommand"
#unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE #unset SSH_AUTH_SOCK SSH_AGENT_PID PKCS11_MODULE
. $agentfile >&2 . $agentfile >/dev/null
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 "PKCS11_MODULE: ${PKCS11_MODULE:-not set}" logdebug "PKCS11_MODULE: ${PKCS11_MODULE:-not set}"
@ -212,7 +212,8 @@ EOF
fi fi
else else
logdebug "Only local agent allowed" logdebug "Only local agent allowed"
if [ -e ${ssh_agentfile} -a $(grep SSH_AUTH_SOCK ${ssh_agentfile}|echo $?) ] loginfo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK} and ssh_agentfile=${ssh_agentfile}"
if [ -e ${ssh_agentfile} -a $(grep SSH_AUTH_SOCK ${ssh_agentfile} >/dev/null; echo $?) -eq 0 ]
then then
logdebug "agentfile exists" logdebug "agentfile exists"
else else
@ -262,6 +263,11 @@ check_pubkeys_and_certs() {
} }
load_or_reload_identities() { load_or_reload_identities() {
# 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
[ $DISPLAY ] && local DISPLAY_ORIG=$DISPLAY
[ $DISPLAY ] && logtrace "unset DISPLAY: $DISPLAY"
[ $DISPLAY ] && unset DISPLAY
logdebug " ssh_idendity=${ssh_identity}" logdebug " ssh_idendity=${ssh_identity}"
logdebug "Now load all identities for ${ssh_identity} from ${ssh_identity_dir}" logdebug "Now load all identities for ${ssh_identity} from ${ssh_identity_dir}"
@ -287,6 +293,7 @@ load_or_reload_identities() {
for pubkey in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/id_*|grep "pub$\|public$"|grep -v "cert.pub"); do for pubkey in $(ls ${SSH_IDENTITIES_DIR}/${ssh_identity}/id_*|grep "pub$\|public$"|grep -v "cert.pub"); do
if $( ls ${pubkey%.pub} 1>/dev/null 2>&1);then if $( ls ${pubkey%.pub} 1>/dev/null 2>&1);then
logdebug "pubkey with privkey: ${pubkey} | ${pubkey%.pub}" logdebug "pubkey with privkey: ${pubkey} | ${pubkey%.pub}"
logdebug "$(ssh-add -T ${pubkey} || ssh-add ${pubkey})"
else else
logdebug "pubkey without privkey: $pubkey" logdebug "pubkey without privkey: $pubkey"
pubkeysonly+=($pubkey) pubkeysonly+=($pubkey)
@ -303,7 +310,7 @@ load_or_reload_identities() {
do do
logdebug "Pubkey: ${pubkey}" logdebug "Pubkey: ${pubkey}"
logdebug " SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" logdebug " SSH_AUTH_SOCK=${SSH_AUTH_SOCK}"
logwarning "$(ssh-add -T ${pubkey} 2>&1)" ssh-add -T ${pubkey} >/dev/null
if [ $? -gt 0 ] if [ $? -gt 0 ]
then then
logdebug "Pubkey ${pubkey} is not usable" logdebug "Pubkey ${pubkey} is not usable"
@ -326,6 +333,9 @@ load_or_reload_identities() {
done done
[ $DISPLAY_ORIG ] && logtrace "reset DISPLAY=$DISPLAY_ORIG"
[ $DISPLAY_ORIG ] && export DISPLAY=$DISPLAY_ORIG
} }
################################################## ##################################################