Community discussions

MikroTik App
 
paku2020
just joined
Topic Author
Posts: 2
Joined: Fri Apr 16, 2021 3:28 pm

Problem with logging from MikroTik to Linux using the ssh key

Fri Apr 16, 2021 4:14 pm

Hello,

I would like to be able to connect via SSH from mikrotik to the Linux server.
For this I need to add an ssh key to be able to login without a password.
I follow the instructions from Wiki
https://wiki.mikrotik.com/wiki/Use_SSH_ ... key_login)
so
I log in to the linux server, execute the command
ssh-keygen -t rsa -m pem
, I am not giving passphrase
[user@server ~/.ssh]$ ssh-keygen -t rsa -m pem
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:qSfhmyyq66ARmOLYEssYRIMEQm9LnyXbYawiIgd4fKo user@server
The key's randomart image is:
+---[RSA 3072]----+
|B= |
|=.o . |
|o.o+.. = |
|o+ooo O .. |
|X.oo =..S |
|OO. .. o |
|Eo. + . |
|oo .. = |
|=+.. .+ |
+----[SHA256]-----+
[user@server ~/.ssh]$
I uploaded the generated keys to RouterOS.
I added publickey to ROS.
From Linux I can log into Mikrotik without using a password.

Now I have done point 7, i.e.
Import both keys for the user:

/user ssh-keys private import user=remote private-key-file=mykey public-key-file=mykey.pub passphrase=""
The keys are imported without any problem or error

According to Wiki, this is the end of the configuration, but I have a problem because I can't log in from Mikrotik on Linux
[user@Dude_v2] > system ssh user=user address=IP command="ip a"
password:
Welcome back!
[user@Dude_v2] > system ssh-exec user=user address=IP command="ip a"
failure: authentication failure
[user@Dude_v2] >
What else should I do?

Who is online

Users browsing this forum: 0xAA55, Bing [Bot] and 37 guests