Hello all,
I was trying to make a passwordless SSH connection to my Mikrotik router (RouterOS 6.49).
There already were some threads about it, like this:
http://forum.mikrotik.com/t/passwordless-ssh-login/35026/1
And there is a documentation about SSH in Mikrotik:
https://help.mikrotik.com/docs/display/ROS/SSH#SSH-SSHServer
But for some reason it doesn’t work for me.
The steps which I did are as follows:
- At the first time that I connected to the Mikrotik device, I imported its public key by entering “yes” to the prompt which followed the command:
$ ssh "$host"
While $host is the IP address of the Mikrotik router.
- I created a public and private key pair with the command:
$ ssh-keygen -t rsa
Which created two files in working directory - let’s call them:
“abc” - the private key.
“abc.pub” - the public key.
I uploaded “abc.pub” to the Mikrotik router via HTTP interface.
Then, I associated that public key to my user (assume that my username is “admin”):
/user ssh-keys import public-key-file=abc.pub user=admin
I can see in webfig that this new public key is truly associated with my user, so it works.
But when I try to do SSH connection from my PC to the Mikrotik device, then it still asks me for a password:
ssh -i "/path/to/private/key/abc" "$host"
Note the configuration:
[admin@Mikrotik] > /ip ssh print
always-allow-password-login: no
I don’t understand why it doesn’t work.
Has anyone encountered this issue?