Ozelo
June 24, 2008, 3:01pm
1
Hi there fellas!
Im following this wiki and so far it works fine. But there are commands that returns some error, ie:
Using this code via remote linux console works fine, also this command works fine via “putty” terminal:
ssh -l admin -i ./id_dsa 10.1.1.1 “/interface wireless access-list print count-only”
BUT using this code, ONLY works via “putty”… Nothing can be done via remote linux console except print stuff?
ssh -l admin -i ./id_dsa 10.1.1.1 “/interface wireless access-list disable 12”
Please, can anyone confirm that? Seems that commands with no other params than the entry ID dont work, i.e: set, unset, enable, disable, remove, etc… Commands like add and print works via remote linux console. Is there some explanation available? tia
Ozelo
try using a space or CRLF at the end of the command, i know certain versions of RouterOS had that problem where a space at the end would fix it. If your not on the latest version upgrade and try again.
Ozelo
June 24, 2008, 6:46pm
3
NOPE… Ive tested on a 3.10 ros with no success. The following command always return “syntax error (line 1 column 29)” meaning that whatever you put after the keyword disable have the same effect:
"/ip firewall mangle disable 0 "
Ozelo
Ozelo
June 24, 2008, 6:51pm
4
These are the codes I am using:
THIS CODE DONT WORK:
<?
function my_ssh_disconnect($reason, $message, $language) {
echo " Server disconnected with reason code $reason and message: $message";
}
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
$connection = ssh2_connect('example.com', 22, $methods, $callbacks);
if (!$connection) echo "Connection failed, ";
else echo "Connected! ";
ssh2_auth_password($connection, 'admin', 'router_passwd');
$stream = ssh2_exec($connection, "/ip firewall mangle disable 0");
sleep(1);
while($line = fgets($stream)) { flush(); echo $line."\n"; }
fclose($stream);
?>
THIS CODE WORKS FINE:
<?
function my_ssh_disconnect($reason, $message, $language) {
echo " Server disconnected with reason code $reason and message: $message";
}
$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'));
$callbacks = array('disconnect' => 'my_ssh_disconnect');
$connection = ssh2_connect('example.com', 22, $methods, $callbacks);
if (!$connection) echo "Connection failed, ";
else echo "Connected! ";
ssh2_auth_password($connection, 'admin', 'router_passwd');
$stream = ssh2_exec($connection, "/ip firewall mangle print");
sleep(1);
while($line = fgets($stream)) { flush(); echo $line."\n"; }
fclose($stream);
?>
Thanks
Ozelo
You can’t tell it item 0 without using print first, which won’t work in your case. Use find to get item 0…
/ip firewall mangle disable [/ip firewall mangle find comment=“RULE0”]
the above finds a rule based on comment, you can have it find based on whatever you need.
Ozelo
June 25, 2008, 2:38pm
6
cheers to changeip
That did the trick! Thank you very much!
Ozelo