blob: 360a2c69f5c745b80d364f4c7ab52f8e41b88518 (
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
30
31
32
33
|
#!/bin/bash
if [ $# -eq 0 ] && [ $(whoami) = 'root' ]; then
getent passwd \
| cut -d: -f1 \
| parallel "${0}"
exit $?
fi
cd "${0%/*}/.."
if [ $# -gt 1 ]; then
>&2 echo 'usage: '"$0"' [user]'
exit 1
fi
host=$(uname -n)
if [ ! -d "hosts/${host}" ]; then
>&2 printf 'no keys for host %s\n' "${host}"
exit 1
fi
user="${1:-$(whoami)}"
home_dir=$(
getent passwd "${user}" \
| cut -d: -f6
)
if [ ! -f "hosts/${host}/${user}" ] && [ ! -f "${home_dir}/.ssh/authorized_keys" ]; then
exit 0
fi
diff -u --color "hosts/${host}/${user}" "${home_dir}/.ssh/authorized_keys"
|