Community discussions

MikroTik App
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 119
Joined: Sat Sep 22, 2018 6:13 pm

reboot another mikrotik from mikrotik device

Sun May 12, 2024 9:42 am

Hello,
i try to reboot a local mikrotik device from another mikrotik.
unfortunately i don't have a linux box with curl or ssh to script and crontab.

so i thought 2 ways...
ssh and rest api

1. rest api i use
/tool/fetch url=https://192.168.1.211:10443/rest/system/scripts/reboot check-certificate=no mode=https user=admin password="mypassword" http-method=get
 status: failed
failure: closing connection: <400 Bad Request> 192.168.1.211:10443 (4)
instead with https://192.168.1.211:10443/rest/system ... s/resource works fine.

or i create a script
:execute {/system reboot;}
but how i can run that script with fetch?

another way is ssh.
so i can create ssh keys and put public on mikrotik to restart. (in system users ssh key import public)
and import in "master" device in system users ssh private key.
but in terminal i can't select ssh private key...
/system/ssh address=192.168.1.211 port=22 user=admin
and then?

i think most convenient use rest api, but i can't understand how integrate with fetch instead curl...

thank you
 
User avatar
patrikg
Member
Member
Posts: 362
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: reboot another mikrotik from mikrotik device

Sun May 12, 2024 10:55 am

You have curl.exe and ssh.exe and scp.exe in windows, and you have at.exe...
at 23:00 /every:M,T,W,Th,F cmd /c "curl.exe https://192.168.1.211:10443/rest/system/scripts/reboot"
And you maybe start the Scheduler.
net start "task scheduler"
And you view the scheduler task just run
at
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 119
Joined: Sat Sep 22, 2018 6:13 pm

Re: reboot another mikrotik from mikrotik device

Sun May 12, 2024 11:32 am

Thank you.
But i don't have Windows server.
So i can't use on Windows PC...

I would reboot lte wap from hap ac3...

Thank you
 
User avatar
patrikg
Member
Member
Posts: 362
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: reboot another mikrotik from mikrotik device

Sun May 12, 2024 11:44 am

ok i see..i think you need to change the content type like this...
http-header-field="Content-Type: application/json" 
/tool/fetch url=https://192.168.1.211:10443/rest/system/scripts/reboot check-certificate=no mode=https user=admin password="mypassword" http-method=get http-header-field="Content-Type: application/json" 
And maybe change http-method=get to post.
 
jaclaz
Forum Guru
Forum Guru
Posts: 1981
Joined: Tue Oct 03, 2023 4:21 pm

Re: reboot another mikrotik from mikrotik device

Sun May 12, 2024 12:02 pm

Who is online

Users browsing this forum: No registered users and 6 guests