File: credentials-ssh-private-keys.sh

package info (click to toggle)
cockpit 337-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 36,232 kB
  • sloc: javascript: 47,090; python: 38,766; ansic: 35,470; xml: 6,048; sh: 3,413; makefile: 614
file content (34 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (20)
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
30
31
32
33
34
#!/bin/sh
set -u

# The first thing we do is list loaded keys
loaded=$(ssh-add -L)
result="$?"

set -e

printf "$loaded"

# Get info for each loaded key
# ssh-keygen -l -f - is not
# supported everywhere so use tempfile
if [ $result -eq 0 ]; then
    tempfile=$(mktemp)
    echo "$loaded" | while read line; do
       echo "$line" > "$tempfile"
       printf "\v%s\v\v" "$line"
       ssh-keygen -l -f "$tempfile" || true
    done
    rm $tempfile
fi

# Try to list keys in this directory
cd "$1" || exit 0

# After that each .pub file gets its on set of blocks
for file in *.pub; do
    printf "\v"
    cat "$file"
    printf "\v%s\v" "$file"
    ssh-keygen -l -f "$file" || true
done