Community discussions

MikroTik App
 
meristo
just joined
Topic Author
Posts: 4
Joined: Sat Oct 14, 2017 11:24 pm

Script for script launch from mikrotik to linux using ssh

Tue Oct 24, 2017 10:36 pm

Hello all,

I created a script for launch a script on my linux server form Mikrotik router using ssh.

This is the script:
/system ssh address=192.168.51.1 user=test command="/bin/bash /opt/bin/power.sh ALL off"

or, only for test also:

/system ssh address=192.168.51.1 user=test command="/bin/echo ciao >>/tmp/ciao"

both works if I launch them from Mikrotik and linux terminal but they do not work if I launch they from Mikrotik "script" interface.

Can you help me?

Thanks
 
meristo
just joined
Topic Author
Posts: 4
Joined: Sat Oct 14, 2017 11:24 pm

Re: Script for script launch from mikrotik to linux using ssh

Thu Oct 26, 2017 10:49 am

Hello all,

it's seems a ROS bug, can I warn Mikrotik team?
 
orsib
just joined
Posts: 7
Joined: Wed Jan 31, 2018 11:57 am

Re: Script for script launch from mikrotik to linux using ssh

Wed Jan 31, 2018 12:10 pm

Hello.

I would like to acheive the something similar.
I would like to connect to my Synology NAS through SSH and execute a shutdown command issued by an UPS monitoring script I have developed and which is running on a mikrotik RB connected to an APC UPS.
My problem is the following. I have generated a DSA public/private keypair on my Synology NAS and using this keypair I can ssh to my Synology NAS using PUTTY on windows, so the server side seems ok. I have imported these keys using /system users ssh-keys private.
The problem is that when I issue the command /system ssh 192.168.1.7 user=orsib, my mikrotik is still requesting for password instead of using the keys to login passwordless. The user is exactly the same I have used to create the keypair on Synology. What is the solution to this? What I should finetune in sshd on Synology in order to get this work?
I would also interested the outcome of this topic as my plan is to issue commands trhough SSH using a script. So if it is not working then it is another obstacle.
 
orsib
just joined
Posts: 7
Joined: Wed Jan 31, 2018 11:57 am

Re: Script for script launch from mikrotik to linux using ssh

Wed Jan 31, 2018 12:15 pm

Hello.

I would like to acheive the something similar.
I would like to connect to my Synology NAS through SSH and execute a shutdown command issued by an UPS monitoring script I have developed and which is running on a mikrotik RB connected to an APC UPS.
My problem is the following. I have generated a DSA public/private keypair on my Synology NAS and using this keypair I can ssh to my Synology NAS using PUTTY on windows, so the server side seems ok. I have imported these keys using /system users ssh-keys private.
The problem is that when I issue the command /system ssh 192.168.1.7 user=orsib, my mikrotik is still requesting for password instead of using the keys to login passwordless. The user is exactly the same I have used to create the keypair on Synology. What is the solution to this? What I should finetune in sshd on Synology in order to get this work?
I would also interested the outcome of this topic as my plan is to issue commands trhough SSH using a script. So if it is not working then it is another obstacle.
 
User avatar
berisz
newbie
Posts: 43
Joined: Tue Dec 12, 2017 12:50 am

Re: Script for script launch from mikrotik to linux using ssh

Fri Sep 10, 2021 11:00 am

The problem is still similar!
Has this ever worked for anyone at all in practice?
> /system ssh-exec address="my.domain.com" port=22 user="user" command=":put 4";
failure: authentication failure 

UPDATE:

Solved!
This command must be issued from the local router, under the user with the private key!

Who is online

Users browsing this forum: No registered users and 19 guests