Debian Codegraph @

pkg/lib/credentials-ssh-private-keys.sh

raw
1 #!/bin/sh
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 set -u
4
5 # The first thing we do is list loaded keys
6 loaded=$(ssh-add -L)
7 result="$?"
8
9 set -e
10
11 printf "$loaded"
12
13 # Get info for each loaded key
14 # ssh-keygen -l -f - is not
15 # supported everywhere so use tempfile
16 if [ $result -eq 0 ]; then
17 tempfile=$(mktemp)
18 echo "$loaded" | while read line; do
19 echo "$line" > "$tempfile"
20 printf "\v%s\v\v" "$line"
21 ssh-keygen -l -f "$tempfile" || true
22 done
23 rm $tempfile
24 fi
25
26 # Try to list keys in this directory
27 cd "$1" || exit 0
28
29 # After that each .pub file gets its on set of blocks
30 for file in *.pub; do
31 printf "\v"
32 cat "$file"
33 printf "\v%s\v" "$file"
34 ssh-keygen -l -f "$file" || true
35 done