How to use output from ssh-exec?

EDIT: first problem was solved I changed the name of the title to match the problem i now have instead of making a entire new thread. I will keep the original issue in case somebody might have a similar issue
My issue now is i cant get ssh-exec’s output set as a variable.


Hello I am trying to set up a SSH key on my mikrotik to login to my linux server to run commands and am completely stumped.

I created a key in my linux server with
“ssh-keygen -t rsa -m PEM”
saved to default location
no password
saved the public key as the "/root/.ssh/authorized_keys files
and imported the set of keys as a private key in my mikrotik.
But when I SSH into linux machine it still asks for a password.
when i turn off password authentication in the ssh server mikrotik just fails to connect it seems.

what am I doing wrong? all the wikis seem to only talk about connecting to a mikrotik through a remote machine. not the other way around.

Figured it out the issue was i was trying to login as root but that was set to no. I changed it so only with the key I can login as root.

But im having issues getting values from my server heres what i have:

:set $name value=[system ssh-exec address=10.100.97.213 user=root command= \ 
"mysql freeradius -e \"SELECT CONCAT(firstname, ' ', lastname) AS 'Full Name' FROM userinfo WHERE username = '$mac';\""]

it returns

exit-code 0
     output: Full Name
                      John Test

which returns just fine. But the variable is still blank. so it didnt use the output.

How do I use the output of ssh-exec?

:set $Query value=[:put ([/system ssh-exec address=10.100.97.213 user=root command= \
("mysql freeradius -e \"SELECT username, '@split', CONCAT(firstname, ' ', lastname) AS 'Full Name' FROM userinfo;\"") as-value]->"output")]

to save output as variable!