#!/bin/sh

clients=/opt/ltsp/$(dpkg --print-architecture)
hostname=$(hostname)
ips=$(getent hosts $hostname | awk '$0 !~ /127.0.0.1/ { print $1 }')
ips=$(ip -o addr show | awk '$3 == "inet" && $4 !~ /^127\./ { print $4 }' | sed -e 's,/[0-9][0-9]*\>,,g')
output=$(tempfile)

names="$hostname $ips"

ssh-keyscan -t rsa,dsa $names > $output

for client in $clients; do
    install -m 644 $output $client/etc/ssh/ssh_known_hosts
done

rm -f $output

exit 0
