What's new

Issue accessing my RT-AC68U using PHP and SSH2

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

jpr105

Occasional Visitor
Hello,

I need to access my RT-AC68U in SSH. So I configured the router as follows:
  • Enable SSH = LAN Only
  • Allow SSH Port Forwarding = Yes (not sure this is necessary)
  • SSH port = 2222
  • Allow Password Login = Yes
  • Enable SSH Brute Force Protection = Yes
When I connect from my iMac or Raspberry, everything is normal.
Code:
ssh Master@192.168.xxx.xxx -p 2222

And I can see my connection on the router's log:
dropbear: Password auth succeeded for 'Master' from 192.168.10.80

This is fine but I especially want to do it in PHP with LibSSH2.

So I wrote this code and it does not work.

PHP:
$ASUS_IP = "IP routeur";
$ASUS_Port = "Port routeur";
$ASUS_User = "User";
$ASUS_Psw = "Password";

$AsusSSH = ssh2_connect ($ASUS_IP, intval($ASUS_Port));
$AsusLogin = ssh2_auth_password ($AsusSSH , $ASUS_User, $ASUS_Psw);

/* Vérification de la connexion */
    
if ($AsusLogin) {
    echo 'Connexion SSH effectu&eacute;<br />';
    } else {
    echo 'Connexion SSH &eacute;chou&eacute;e<br />';
}

RT-AC68U Log
dropbear: Login attempt for nonexistent user from 192.168.10.80
PHP Log
PHP Warning: ssh2_auth_password (): Authentication failed for Master using password

Can someone help me please?

Thank you in advance

Regards - Jean-Paul
 
The log complains about a non-existing user, so that's probably your problem - double check the user.
 
You were right, the problem was on my side and it works now ... I can now connect to my router without problems :)

The purpose of my PHP script is to turn ON or OFF, "on demand", my 2.4Ghz wifi signal.

I tested these commands successfully:
Code:
wl -i eth1 radio on
wl -i eth1 radio off

But before using them, I wonder if there is an easy command to know the state of the radio signal (on or off) before changing it.

Thanks
 
Hello,

To complete my last post, I noticed there was no synchronization between the action (wl -i eth1 radio on or wl -i eth1 radio off) and the Web GUI and I do not find this very "clean" :(.

I found another method on this forum ... is it better?

Code:
#get 2,4ghz radio status
nvram get wl_radio

#turn off 2.4ghz
nvram set wl_radio = 0
nvram commit
restart_wireless service

#turn on 2,4ghz
nvram set wl_radio = 1
nvram commit
restart_wireless service

#get 5ghz radio status
nvram get wl1_radio

#turn off 5ghz
nvram set wl1_radio = 0
nvram commit
restart_wireless service

#turn on 5ghz
nvram set wl1_radio = 1
nvram commit
restart_wireless service

Thanks
 
Yes, as that would be done at the firmware level, rather than poking directly at the radio level (where it might leave you with out of sync settings as you've noticed).

Note however that for 2.4 GHz, the correct variable is wl0_radio, not wl_radio.
 
Thanks a lot @RMerlin and @ColinTaylor,

I think I have everything I need to succeed in my project.

I test and come back to post my solution if it can help someone else.

Thanks again.

Regards - Jean-Paul
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top