Here is an explanation of Mikotiks ed25591 host key files and the issues manipulating them. Hold on because this will take a while.
Generate a new ed25591 host certificate on your Mikrtik router:
[MikroTik] > /ip/ssh/print
ciphers: auto
forwarding-enabled: no
always-allow-password-login: no
strong-crypto: yes
host-key-size: 2048
host-key-type: ed25519
[MikroTik] > /ip/ssh/regenerate-host-key
This will regenerate current SSH host keys, yes? [y/N]:
y
16:19:41 echo: ssh,critical SSH host key regenerated!
[MikroTik] > /ip/ssh/export-host-key key-file-prefix=mikrotik
16:20:42 echo: ssh,critical SSH host keys exported to mikrotik_ed25519
[johns@MikroTik] > /file print
# NAME TYPE SIZE LAST-MODIFIED
1 mikrotik_ed25519_pub.pem pem file 113 2025-07-10 16:20:42
2 mikrotik_ed25519.pem pem file 119 2025-07-10 16:20:42
[MikroTik] > :put [/file/get mikrotik_ed25519.pem contents]
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIP/6e1tHq6xA5WbiWULDCeakQdzIsNEzcRG0rZFiQbzs
-----END PRIVATE KEY-----
[MikroTik] > :put [/file/get mikrotik_ed25519_pub.pem contents]
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAmRlfVmthnWcRbWGIuZZuFACG5bIXO/M+MnCZnmirMHc=
-----END PUBLIC KEY-----
Transfer this key file over to a computer to do more analysis. I used one running Debian Bookworm.
This private host key is in pkcs#8 format and PEM encoding. This is similar to a key created with openssl using
openssl genpkey -algorthm ed25519 -out mikrotik_ed25519.pem
To create an ssh fingerprint like will be reported when we first connect we would ordinarily use ssh-keygen from OpenSSH,
but it does not recognize this key. It seems that until recently OpenSHH did not fully support ed25519 type keys.
see:
https://bugzilla.mindrot.org/show_bug.cgi?id=3195 Bug 3195 - ssh-keygen unable to convert ED25519 public keys
fixed in openssh-9.6
I have an earlier version, so until I can upgrade to Debian testing Ill have to find a way.
$ sudo apt-cache policy openssh-client
openssh-client:
Installed: 1:9.2p1-2+deb12u5
OpenSSH ssh-keygen fails to recognize this host key file.
$ ssh-keygen -l -f mikrotik_ed25519.pem
mikrotik_ed25519.pem is not a key file.
I found a very handy bash script that will do the conversion until then in this conversation (its not really attributed, so I dont know who to thank):
https://security.stackexchange.com/questions/267711/how-can-i-convert-an-ed25519-key-in-pkcs8-to-openssh-private-key-format
eddsa-ssl-to-ossh.sh
#!/bin/sh
set -euf
ssl_priv=$(cat ${1:+"$1"})
pub64=$(echo "$ssl_priv" | openssl pkey -pubout -outform der 2>/dev/null | dd bs=12 skip=1 status=none | base64)
test "$pub64" || { echo "Cannot get public key" >&2; exit 1; }
priv64=$(echo "$ssl_priv" | grep -v '^-' | base64 -d | dd bs=16 skip=1 status=none | base64)
echo '-----BEGIN OPENSSH PRIVATE KEY-----'
{
printf openssh-key-v1'\000\000\000\000\004'none'\000\000\000\004'none'\000\000\000\000\000\000\000\001\000\000\000'3
printf '\000\000\000\013'ssh-ed25519'\000\000\000 '
echo $pub64 | base64 -d
printf '\000\000\000'
printf '\210\000\000\000\000\000\000\000\000'
printf '\000\000\000\013'ssh-ed25519'\000\000\000 '
echo $pub64 | base64 -d
printf '\000\000\000@'
echo $priv64| base64 -d
echo $pub64 | base64 -d
printf '\000\000\000\000\001\002\003\004\005'
} | base64
echo '-----END OPENSSH PRIVATE KEY-----'
Manipulate the host key file
$ chmod 0600 mikrotik_ed25519.pem
$ bash ./eddsa-ssl-to-ossh.sh mikrotik_ed25519.pem > mikrotik_ed25519.openssh.pem
# this is now in OpenSSH format
$ cat mikrotik_ed25519.openssh.pem
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZWQyNTUx
OQAAACCZGV9Wa2GdZxFtYYi5lm4UAIblshc78z4ycJmeaKswdwAAAIgAAAAAAAAAAAAAAAtzc2gt
ZWQyNTUxOQAAACCZGV9Wa2GdZxFtYYi5lm4UAIblshc78z4ycJmeaKswdwAAAED/+ntbR6usQOVm
4llCwwnmpEHcyLDRM3ERtK2RYkG87JkZX1ZrYZ1nEW1hiLmWbhQAhuWyFzvzPjJwmZ5oqzB3AAAA
AAECAwQF
-----END OPENSSH PRIVATE KEY-----
# change permissions to be restrictive
$ chmod 0600 mikrotik_ed25519.openssh.pem
#
# OpenSSH can now work with this file and give the fingerprint
# this matches the fingerprint from the first SSH session
$ ssh-keygen -lf mikrotik_ed25519.openssh.pem
256 SHA256:nU+v64Ko6LnBh+ijYuWprosuHmtDQ+u+hgJ3+slLYhI (ED25519)
# Create an OpenSSH public key from the private key
$ ssh-keygen -y -f mikrotik_ed25519.openssh.pem > mikrotik_ed25519.openssh.pub.pem
# This public key matches the enty in known_hosts
$ cat mikrotik_ed25519.openssh.pub.pem
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJkZX1ZrYZ1nEW1hiLmWbhQAhuWyFzvzPjJwmZ5oqzB
First attempt to SSH with new key. Note this matches the fingerprint above.
$ ssh mikrotik@192.168.1.1
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
ED25519 key fingerprint is SHA256:nU+v64Ko6LnBh+ijYuWprosuHmtDQ+u+hgJ3+slLYhI.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.1' (ED25519) to the list of known hosts.
known_hosts matches OpenSSH public key above.
$ grep "192\.168\.1\.1 " ~/.ssh/known_hosts
192.168.1.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJkZX1ZrYZ1nEW1hiLmWbhQAhuWyFzvzPjJwmZ5oqzB3