[vox-tech] ssh host key generation in init script

Nick Schmalenberger nick at schmalenberger.us
Wed Dec 23 17:53:59 PST 2009


Hi,
I need to be able to generate ssh host keys at boot time instead
of installation if they don't exist. CentOS and upstream openssh
handle this in the init script with ssh-keygen, but debian calls
it from /var/lib/dpkg/info/openssh-server.postinst. I put 
ls /etc/ssh/ssh_host_* &> /dev/null || /usr/sbin/dpkg-reconfigure
openssh-server in a function in /etc/init.d/ssh and it works
fine, but ubuntu uses dash instead and it says
ls: cannot access /etc/ssh/ssh_host_*: No such file or directory
when ls is true. I also tried
test -f /etc/ssh/ssh_host_* || /usr/sbin/dpkg-reconfigure
openssh-server and it says test: 1: /etc/ssh/ssh_host_dsa_key:
unexpected operator when the test is true. Can someone help me
make this more portable? Thanks!
Nick Schmalenberger


More information about the vox-tech mailing list