Community discussions

 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Script communication between multiple routers?

Sat Feb 16, 2013 4:31 pm

is there a way to call a script on one router to execute a script on another router?

thanks in advance,
 
User avatar
ohara
Member
Member
Posts: 371
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: Script communication between multiple routers?

Sat Feb 16, 2013 5:38 pm

This command executes the script 'yourscript' on router 192.168.1.2. The script is saved on the same router that it is executed on.

ros code

system ssh 192.168.1.2 user=admin "/system script run yourscript"
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Script communication between multiple routers?

Sat Feb 16, 2013 6:45 pm

excellent, my road here is "ssh".

Thank you & Please accept my Karma :D
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Script communication between multiple routers?

Sun Mar 31, 2013 6:19 pm

without having a linux box, how to create a passkey so it won't ask for password?

this is script communications between mikrotik to mikrotik only.

thanks in advance..
 
User avatar
ohara
Member
Member
Posts: 371
Joined: Mon Jun 13, 2011 11:30 pm
Location: Warsaw

Re: Script communication between multiple routers?

Sun Mar 31, 2013 8:32 pm

This can be achieved with importing ssh public key on your mikrotik device.
http://wiki.mikrotik.com/wiki/Use_SSH_t ... key_login)
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Script communication between multiple routers?

Mon Apr 01, 2013 1:14 am

the wiki provided involve linux box. is there any way to use just mikrotik routers?

i was able to create a user on remote mikrotik device without password and log-in using terminal
/system
ssh 192.168.1.1 user=myuser

but when using the same user in a script won't work
/system ssh 192.168.1.1 user=myuser ":log info hello"
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Script communication between multiple routers?

Mon Apr 01, 2013 2:41 am

I followed the guide and still not a good result:

on ubuntu:

ssh-keygen -t dsa
Enter file in which to save the key:
"key"
no password

both file key & key.pub was copied to both routers (routerA and routerB)
on routerA
create user sshadmin (no password)
import ssh key
user = sshadmin
key file = key.pub

on routerB
create user sshadmin (no password)
import ssh private key
user = sshadmin
public key file = key.pub
private key file = key
passphrase = (blank)

on routerB create new script
/system ssh 192.168.1.1 user=sshadmin ":log info hello"

what's my mistake here?

thanks,
 
User avatar
payday
Member Candidate
Member Candidate
Posts: 233
Joined: Thu Aug 16, 2012 11:05 pm

Re: Script communication between multiple routers?

Tue Apr 02, 2013 8:31 pm

You can also try an xxxx.auto.rsc file:
"Since RouterOS v3rc it is possible to automatically execute scripts - your script file has to be called anything.auto.rsc - once this file is uploaded with FTP to the router, it will automatically be executed, just like with the Import command."
Source: http://wiki.mikrotik.com/wiki/Manual:Co ... Management

To upload file you can use /tool fetch command, example:
[admin@mt-test] /tool> fetch address=192.168.88.2 src-path=conf.rsc user=admin mode=ftp password=123 dst-path=123.auto.rsc upload=yes
Source: http://wiki.mikrotik.com/wiki/Manual:Tools/Fetch

But, be aware of some bugs: http://forum.mikrotik.com/viewtopic.php?f=9&t=62261

Who is online

Users browsing this forum: No registered users and 9 guests