Community discussions

 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

How to connect via ssh from MT to another MT to send command

Sat Feb 09, 2008 1:29 pm

Hi everyone,
I need some help, so I want my MT Router (2.9.50) to Connect via SSH to another MT Router (2.9.50) to send some command (say run some script or something like that).
Can You Help Me ?
I have tried this setup connecting from linux. My SSH had no password and it was working very Well.
Now I need to do this Setup, Please Help, I can not write the expresion right, inorder it works.

With Great Regards
Karapet Aznavuryan
 
codeesan
just joined
Posts: 5
Joined: Sun Jun 18, 2006 9:26 pm

Re: How to connect via ssh from MT to another MT to send command

Mon Mar 03, 2008 9:21 pm

I am currently working on a similar issue.

I have one mikrotik trying to fetch information from another.

I can start the session but cannot issue commands to the remote MT.

Cody
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: How to connect via ssh from MT to another MT to send command

Mon Mar 03, 2008 9:35 pm

Can You send me the script?
 
codeesan
just joined
Posts: 5
Joined: Sun Jun 18, 2006 9:26 pm

Re: How to connect via ssh from MT to another MT to send command

Mon Mar 03, 2008 11:29 pm

/system ssh 66.134.x.x user=malibu+ct
:delay 10
:global malibuAddress [interface pptp-server get fromMalibu client-address]
/quit


I would like to connect via ssh issue the command to get the client address form the pptp-server then quit out of the ssh session.

I have tried while (/system ssh 66.134.x.x user=malibu) do={
:delay 10
:global mal........
/quit
}

but to no avail.
Last edited by codeesan on Sat Mar 29, 2008 12:22 am, edited 1 time in total.
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: How to connect via ssh from MT to another MT to send command

Tue Mar 04, 2008 12:06 am

I have tried, but no use,
I could not even create a session,
Try using this for getting pptp-server client-address,
:global malibuIP [/interface pptp-server get [/interface pptp-server find user=Mag ] client-address ]
:log error $malibuIP
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: How to connect via ssh from MT to another MT to send command

Tue Mar 04, 2008 12:26 am

Look the MikroTik Support Center Has Answered to My question.
Hello,
you cannot execute remote commands through ssh from router, you can do that
from any other linux host that is available to you.

also access to router without password is not advised to, as a better practice
use key to log in remotely through ssh and in your script point to a key file,
so your router is protected.

Regards,
Janis
I think We have to find another way to solve this proble.
Thanks With Best Regards
Karapet Aznavuryan
 
codeesan
just joined
Posts: 5
Joined: Sun Jun 18, 2006 9:26 pm

Re: How to connect via ssh from MT to another MT to send command

Tue Mar 04, 2008 7:02 pm

The code that I posted works fine locally but I was unable to send commands over the ssh.

I do appreciate the time and definate answer to the question.

Thanks again,

Cody
 
gabriellauter
newbie
Posts: 25
Joined: Mon Aug 27, 2007 11:02 pm

Re: How to connect via ssh from MT to another MT to send command

Mon Apr 14, 2008 11:02 pm

could you please tell me how to run a script remotelly from a linux box?

and how could i do that having the the script file only on the linux machine?

thanks.

gabriel
brazil
 
User avatar
karo84
Member Candidate
Member Candidate
Topic Author
Posts: 194
Joined: Fri Aug 17, 2007 9:06 am

Re: How to connect via ssh from MT to another MT to send command

Tue Apr 15, 2008 3:00 pm

First of All You have to generate public key, and then You can use say such command
PPP active print
You must put the same key in your mikrotik router,
user ssh-keys import file="your pub key "
running
ssh 192.168.250.250 -l admin -i .ssh/id_dsa /ppp active print
command on linux will print active connection.

With Best regards
Karapet Aznavuryan
 
cieplik206
Trainer
Trainer
Posts: 286
Joined: Sun Jul 01, 2007 12:25 am
Contact:

Re: How to connect via ssh from MT to another MT to send command

Sun Apr 20, 2008 2:18 pm

hey guys

Maybe other way will be nice to use as well

As MT3.x got a basic http/ftp client (/tool fetch)

it is possible that remote router will have a script scheduled every some period of time that will do:

1. Download script file from remote location
2. run that script

if you want results from remote router like stats, logs, signals etc... you can use SSH with RSA/DSA keys to avoid login and password. that can be done easly from linux, never tried it from MT to MT but i believe if MT boxes will have pairs of public/prvate should work the same.

Other option is to write s simple script to get few values and send it via remote syslog to a Linux machine. and use a script on linux machine to check syslog and take action depends what is in syslog.

Answer for "How to do it" depends "What do you want"
https://www.wispcasts.com - Mikrotik Video Tutorials.

The best place where you can improve your skills!

Facebook - F/wispcasts
Twitter - @wispcasts

Who is online

Users browsing this forum: MSN [Bot] and 11 guests