diff --git a/tinyssh_install b/tinyssh_install index e207034..da572cf 100644 --- a/tinyssh_install +++ b/tinyssh_install @@ -9,7 +9,37 @@ display_fingerprints() { generate_keys() { if [ ! -d /etc/tinyssh/sshkeydir ]; then tinysshd-makekey /etc/tinyssh/sshkeydir + if [ $? -eq 0 ]; then + echo "Generated tinyssh keys..." + return 0 + fi fi + return 1 +} + +copy_openssh_keys() { + local osshed25519="/etc/ssh/ssh_host_ed25519_key" + + local destdir="/etc/tinyssh/sshkeydir" + + local return_code=1 + + if [ ! -d $destdir -a -x /usr/bin/tinyssh-convert ]; then + mkdir $destdir + fi + + if [ -s "$osshed25519" -a ! -s $destdir/.ed25519.sk -a ! -s $destdir/ed25519.pk -a -x /usr/bin/tinyssh-convert ]; then + tinyssh-convert -f $osshed25519 -d $destdir + if [ $? -eq 0 ]; then + return_code=0 + fi + fi + + if [ $return_code -eq 0 ]; then + echo "Converted keys from OpenSSH..." + fi + + return $return_code } create_systemd_customdep () { @@ -41,7 +71,7 @@ build () umask 0022 - generate_keys + copy_openssh_keys || generate_keys display_fingerprints #systemd enabled