#!/bin/sh

if [ -e /etc/ssh/sshd_not_to_be_run ]; then exit 161; fi
mkdir -p /run/sshd
chmod 0755 /run/sshd
# ensuring privilege seperation user sshd exists 
if id -u sshd >/dev/null 2>&1 ; then 
echo "User 'sshd' already exists"
else useradd -r sshd -s /bin/nologin >/dev/null 2>&1
fi
ssh-keygen -A
touch /var/log/lastlog
chgrp utmp /var/log/lastlog
chmod 664 /var/log/lastlog
/usr/sbin/sshd -t || exit 162
/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config
