MikroTik firmware version is 6.48.6 (long-term)
Trying to achieve passwordless access via ssh, following the 3 steps from https://wiki.mikrotik.com/wiki/Use_SSH_to_execute_commands_(public/private_key_login)#Host_to_RouterOS
First I tried with a dedicated user, failed, tried with default admin, failed. Here for simplicity lets talk about admin.
Issues:
- Can’t access
ssh -i ~/.ssh/to_MikroTik admin@192.168.88.1
passwordless having installed “to_MikroTik.pub” key;
- Can’t access
ssh admin@192.168.88.1
with password - “Permission denied, please try again.”. I copy password from a password manager, no typos, but ssh doesn’t let me in, whereas I can access via webfig, delete ssh key at
System → Users → SSH Keys
and then I can again
ssh admin@192.168.88.1
with password
Commands:
ssh-keygen -t rsa -m PEM -f ~/.ssh/to_MikroTik
http://man.openbsd.org/ssh-keygen says uppercase “PEM”, not lowercase “pem” as MikroTik Wiki says.
Double Enter for empty passphrase.
cd ~/.ssh/
ftp 192.168.88.1
put to_MikroTik.pub
^D
ssh admin@192.168.88.1
user ssh-keys import public-key-file=to_MikroTik.pub
^D
Wiki has it:
user: admin-ssh
it looks like a prompt is to be displayed, I get nothing like this, even with another user pre-created.
If I understand it right, I should be able to passwordlessly ssh into MikroTik with:
ssh -i ~/.ssh/to_MikroTik admin@192.168.88.1
or passwordlessly execute commands e.g. see leases with:
ssh -i ~/.ssh/to_MikroTik admin@192.168.88.1 ip dhcp-server lease print
but it doesn’t happen.
So, what is the way to make it happen?
Also, Wiki:
3) Now from either Winbox or terminal mode you need to import the key.
Why webfig isn’t mentioned?