How can I send a command to Mikritik via SSH? For example I want to send this command: /ip service disable telnet. U tried ssh admin@xxx.xxx.xxx.xxx /ip service disable telnet, but no reaction on the router.
Read this thread:
http://www.mikrotik.com/forum/viewtopic.php?t=1957
It’s the one right below yours…
Yes, I read this topic and I also tried this script. But I use Debian and the script only log to Mikrotik, but then its will freeze. No commands are executed. All required modules are downloaded from CPAN. Did you test it on Debian or have you some advice for me?
Does it really metter if it’s Debian or Solaris or IRIX or MacOS X?
All you need is correct perl path and the required modules.
It works on FreeBSD and Gentoo here.
Bet it’d work on Windows as well.
O.K., now it´s works, there was an error in perl. But now I have another problem. When I run this script on console, it´s OK. But when I want to run it in CRON, the script will freeze. In cron I have “/path/ssh.cmd IP /path/cmd”.
Drop perl, it’s bad for you
Run the same thing with expect
#!/usr/bin/expect
spawn /usr/bin/ssh host -l user
expect -re "password: "
send “'yourpass\r”
expect -re "] > "
send “yourcommand\r”
sleep 2
expect -re "] > " exit
log from cronjob:
spawn /usr/bin/ssh 10.1.2.1 -l stats
stats@10.1.2.1’s password:
ip firewall mangle reset-counters
ip?
When I run script on console, everything is working, but still not in cronjob..