summaryrefslogtreecommitdiff
path: root/src/endofossil
blob: 401806fa443d4ef0f3a542b6aa9565c07df989f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -e


IFS=/ read n pid uid <<< "$1"
[ "$pid" ]

authtype=
while read -d ''
do
    case "${REPLY%%=*}" in
        'SSH_USER_AUTH' ) read authtype keytype keyvalue < "${REPLY#*=}" ;;
    esac
done < /proc/$pid/environ
[ "$authtype" = publickey ]

keyhash=
while read
do
    set -- $REPLY
    if [ "$3 $5" = 'SSHFP 2' ]
    then
        keyhash=$6
        break
    fi
done < <(ssh-keygen -f <(printf '%s\n' "$keytype $keyvalue") -r .)
[ "$keyhash" ]

printf '%s\n' "$keyhash"