If you intent to make use of a RSA key make sure you are running RouterOS 6.31 version or above, otherwise you may receive an error like this one unable to load key file (incorrect passphrase?) !. If the installation needs to be update then refer to this post on How to Upgrade RouterOS from the Command Line. NOte: you need access to a Linux system to generate the private and public key pair.
Use the ssh-keygen command to generate an RSA key pair. This step is almost automated for you just wait.
ssh-keygen -t rsa
You can view the key pair in their respective directory. Remember: id_rsa.pub is meant to be public and will be the file we upload to the remote system.
The key pair will reside in the ~/.ssh found in the users home directory. Use SCP to copy the public key pair from the Linux system over to the Mikrotik RouterOS system just change the IP address to that of your router.
scp ~/.ssh/id\_rsa.pub email@example.com:id\_rsa.pub
Now log-in to RouterOS and import id_rsa.pub key we just uploaded. I’m importing a key for the user admin you can change this to the of any other user.
/user ssh-keys import public-key-file=id\_rsa.pub user=admin
Let’s view the user new SSH key.
/user ssh-keys print