#!/bin/bash

. ${TOOLKIT}-functions.sh

file="ssh.default"
target="/etc/default/ssh"

[ -f $target ] || {
	installfile $file $target root:root 664
}

# make sure that we have all the host keys
#
keytypes=$(jtconf sshd.hostkeys_types)

for keytype in $keytypes
do
	file="/etc/ssh/ssh_host_${keytype}_key"
	if [ -f "$file" ]
	then
		# just check/fix permissions
		installfile $file $file root:root 600
	else
		ssh-keygen -N "" -t $keytype -f $keytype.tmp
		installfile $keytype.tmp $file root:root 600
	fi
done
		
$SOMETHING_CHANGED && {
	restart_service ssh sshd || exit 1
}
exit 0
