File: credentials-ssh-private-keys.sh

package info (click to toggle)
cockpit 239-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 67,268 kB
  • sloc: javascript: 245,474; ansic: 72,273; python: 23,634; xml: 6,155; sh: 2,919; makefile: 923; sed: 5
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