All pastes #462571 Raw Edit

ltsp-update-sshkeys

public shellscript v1 · immutable
#462571 ·published 2007-04-28 11:32 UTC
rendered paste body
#!/bin/shtest -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="/tmp/output"enc="dsa rsa"names="$hostname $ips"logfile="/var/log/messages"if [ -z "$clients" ]; then	logger -f $logfile -t ltsp "No client chroots found, please run ltsp-build-client"	exit 0fifor 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    donedoneif [ -f /etc/ltsp/ssh_known_hosts.extra ]; then    cat /etc/ltsp/ssh_known_hosts.extra >> $outputfiecho "Setting up ssh_known_hosts in: "for client in $clients; do    echo "  $client"    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..."    fidonerm -f $outputexit 0