File: ltsp-update-sshkeys

package info (click to toggle)
ltsp 0.99debian11
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 976 kB
  • ctags: 103
  • sloc: sh: 1,320; python: 485; ansic: 436; lex: 152; makefile: 129; yacc: 58
file content (43 lines) | stat: -rw-r--r-- 1,234 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
#!/bin/sh

test -z "$clients" && clients=$(find /opt/ltsp/. -mindepth 1 -maxdepth 1 -type d 2>/dev/null)
hostname=$(hostname)
ips=$(ip -o addr show | awk '$3 == "inet" && $4 !~ /^127\./ { print $4 }' | sed -e 's,/[0-9][0-9]*\>,,g')
output=$(tempfile)
enc="dsa rsa"

names="$hostname $ips"

logfile="/var/log/syslog"

if [ -z "$clients" ]; then
	logger -f $logfile -t ltsp "No client chroots found, please run ltsp-build-client"
	exit 0
fi

for name in $names; do
    for encryption in $enc; do
		if [ -f /etc/ssh/ssh_host_${encryption}_key.pub ]; then
			echo $(echo $name $(cat /etc/ssh/ssh_host_${encryption}_key.pub|awk '{split ($0, a, " "); print a[1]" "a[2]" "}')) >> $output
			logger -f $logfile -t ltsp "# Creating ${encryption}-hostkey for $name"
		else
			logger -f $logfile -t ltsp "No ${encryption} key found for ${name}, please configure your ssh server correctly"
		fi
    done
done

if [ -f /etc/ltsp/ssh_known_hosts.extra ]; then
    cat /etc/ltsp/ssh_known_hosts.extra >> $output
fi

for client in $clients; do
    if [ -d $client/etc/ssh ]; then
        install -m 644 $output $client/etc/ssh/ssh_known_hosts
    else
        echo "WARNING: $client/etc/ssh not found. skipping..."
    fi
done

rm -f $output

exit 0