#!/bin/sh -e

if [ -f /etc/ssh/ssh_host_key ]
then
	echo "You already have a host key in /etc/ssh/ssh_host_key."
else
	umask 022; echo "Generating 1024 bit host key."; \
	openssh-keygen -b 1024 -f /etc/ssh/ssh_host_key -N ''
fi

  # check to see if Berkley protocols are still active
  if grep -q "^\(login\|shell\|exec\)\b" /etc/inetd.conf
  then
    echo
    echo "For OpenSSH to be effective you should disable rsh, rlogin and rexec"
    echo -n "Do you want to do this right now? (y/n) [y] "
    read input
    if [ -z "$input" ] || expr "$input" : '[Yy]' >/dev/null
    then
      cat <<EOF
Disabling rsh, rlogin and rexec .....
You can enable them again with:    update-inetd --enable login,shell,exec
EOF
      update-inetd --comment-chars '#<openssh># ' --disable login,shell,exec
    fi
  fi

#DEBHELPER#
