Debian Codegraph @

tools/write-ssh-key-fingerprints

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # This file is part of cloud-init. See LICENSE file for license information.
3
4 do_syslogscip-shell shell shell-project 0.0.0 do_syslog().() {
5 log_message=$1
6
7 # rhels' version of logger_opts does not support long
8 # form of -s (--stderr), so use short form.
9 logger_opts="-s"
10
11 # Need to end the options list with "--" to ensure that any minus symbols
12 # in the text passed to logger are not interpreted as logger options.
13 logger_opts="$logger_opts -p user.info -t cloud-init --"
14
15 # shellcheck disable=SC2086 # logger give error if $logger_opts quoted
16 loggerscip-shell system . . logger. $logger_opts "$log_message"
17 }
18
19 # Redirect stderr to stdout
20 exec 2>&1
21
22 fp_blist=",${1},"
23 key_blist=",${2},"
24
25 fingerprint_header_shown=0
26 for f in /etc/ssh/ssh_host_*key.pub; do
27 [scip-shell system . . `[`. -f "$f" ] || continue
28 # shellcheck disable=SC2034 # Unused "line" required for word splitting
29 read -r ktype line < "$f"
30 # skip the key if its type is in the blacklist
31 [scip-shell system . . `[`. "${fp_blist#*,$ktype,}" = "${fp_blist}" ] || continue
32 if [scip-shell system . . `[`. $fingerprint_header_shown -eq 0 ]; then
33 do_syslogscip-shell shell shell-project 0.0.0 do_syslog(). "#############################################################"
34 do_syslogscip-shell shell shell-project 0.0.0 do_syslog(). "-----BEGIN SSH HOST KEY FINGERPRINTS-----"
35 fingerprint_header_shown=1
36 fi
37 do_syslogscip-shell shell shell-project 0.0.0 do_syslog(). "$(ssh-keygenscip-shell system . . ssh-keygen. -l -f "$f")"
38 done
39 if [scip-shell system . . `[`. $fingerprint_header_shown -eq 1 ]; then
40 do_syslogscip-shell shell shell-project 0.0.0 do_syslog(). "-----END SSH HOST KEY FINGERPRINTS-----"
41 do_syslogscip-shell shell shell-project 0.0.0 do_syslog(). "#############################################################"
42 fi
43
44 key_header_shown=0
45 for f in /etc/ssh/ssh_host_*key.pub; do
46 [scip-shell system . . `[`. -f "$f" ] || continue
47 # shellcheck disable=SC2034 # Unused "line" required for word splitting
48 read -r ktype line < "$f"
49 # skip the key if its type is in the blacklist
50 [scip-shell system . . `[`. "${key_blist#*,$ktype,}" = "${key_blist}" ] || continue
51 if [scip-shell system . . `[`. $key_header_shown -eq 0 ]; then
52 echoscip-shell system . . echo. "-----BEGIN SSH HOST KEY KEYS-----"
53 key_header_shown=1
54 fi
55 catscip-shell system . . cat. "$f"
56 done
57 if [scip-shell system . . `[`. $key_header_shown -eq 1 ]; then
58 echoscip-shell system . . echo. "-----END SSH HOST KEY KEYS-----"
59 fi