Theo has suggested that it would be nicer if the "generating new
host key" output was all on one line.
Basically we want "ssh-keygen: generating new host key:" to start
the line, followed by the algorith name as each key is generated.
In the unlikely event that an error happens, ssh-keygen will complain
verbosely, and we're again at the start of a line.
Here's what I currently have, but I'm not very happy with it.
ssh_keys=0
if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
if [ $((ssh_keys++)) -eq 0 ]; then
echo -n "ssh-keygen: generating new host key:"
fi
echo -n " DSA..."
if ! /usr/bin/ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -N '';
then
ssh_keys=0
fi
fi
if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then
if [ $((ssh_keys++)) -eq 0 ]; then
echo -n "ssh-keygen: generating new host key:"
fi
echo -n " ECDSA..."
if ! /usr/bin/ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N
''; then
ssh_keys=0
fi
fi
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
if [ $((ssh_keys++)) -eq 0 ]; then
echo -n "ssh-keygen: generating new host key:"
fi
echo -n " RSA..."
if ! /usr/bin/ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -N '';
then
ssh_keys=0
fi
fi
if [ ! -f /etc/ssh/ssh_host_key ]; then
if [ $((ssh_keys++)) -eq 0 ]; then
echo -n "ssh-keygen: generating new host key:"
fi
echo -n " RSA1..."
/usr/bin/ssh-keygen -q -t rsa1 -f /etc/ssh/ssh_host_key -N ''
fi
if [ $ssh_keys -gt 0 ]; then
echo
fi
--
Christian "naddy" Weisgerber [email protected]