mkdir /.ssh 2> /dev/null
cp /etc/tux/pkg/opensshd/keys /.ssh/authorized_keys 2> /dev/null
mkdir -p /usr/local/etc
cd /usr/local/etc
touch sshd_config

# generate host keys

if [ -f /etc/tux/pkg/opensshd/identity.tar ]
then
	cp /etc/tux/pkg/opensshd/identity.tar /.ssh/
	cd /.ssh
	tar xf identity.tar
	rm identity.tar
else

	echo "[Generating public/private keypair(s) for root]"
	ssh-keygen -q

	echo "Adding RSA keys to /etc/tux/. Be sure to saveconfig"
	echo "so they will get copied to the boot floppy"
	cd /.ssh
	tar cf /etc/tux/pkg/opensshd/identity.tar identity*
fi

if [ -f /etc/tux/pkg/opensshd/hostkeys.tar ]
then
	cp /etc/tux/pkg/opensshd/hostkeys.tar /usr/local/etc/
	cd /usr/local/etc/
	tar xf hostkeys.tar 
	rm hostkeys.tar
else
	cd /usr/local/etc/
	echo "[Generating public/private keypair(s) for this host]"
	ssh-keygen -q -b 1024 -f ssh_host_key -N ""
	ssh-keygen -q -d -f ssh_host_dsa_key -N ""

	echo "Adding host keys to /etc/tux/. Be sure to saveconfig"
	echo "so they will get copied to the boot floppy"
	tar cf /etc/tux/pkg/opensshd/hostkeys.tar ssh_host*
fi



echo "Starting sshd"
/usr/local/sbin/sshd
cd /
