Add option to create host_key directory if it doesn't exist

Fixes #6731