ASUSWRT device_tracker not working with Hassio

I’m running Hassio 0.62.0 on a RPi3 and I was setting up device_tracker to an ASUS RT-AC68U running the latest 3.0.0.4.384 firmware. Since it hasn’t worked at all I’ve been going all over other forum posts and other suggestions trying a variety of items that have fixed this for other people. This is the error I get over and over without any other errors related to SHH in the logs.

ERROR (SyncWorker_1) [homeassistant.components.device_tracker.asuswrt] Connection refused. SSH enabled?

My configuration.yaml I’m at now after trying various suggestions to increasing the interval and different locations for the private key. I made the private key in puttygen and saved it with no password and put the public key portion it generated into my ASUS router. I set a wrong path on one try to make sure it was reading it correctly and caused an error about the key not existing then but when it’s correct no errors.

device_tracker:

  • platform: asuswrt
    host: 192.168.1.1
    interval_seconds: 30
    protocol: ssh
    port: 22
    mode: router
    track_new_devices: yes
    consider_home: 180
    username: MyAdminName
    ssh_key: /config/.ssh/private.ppk

If I load the private key in Putty I can connect to the ASUS without issue. If I SSH to the Hassio install I can SSH to the ASUS as well using the private key. However in both of those cases I had to validate the connection into either the Windows registry or in the case of SSH in Hassio the ~/.ssh/known_hosts file (which is actually gone now after rebooting). Also in both of those cases once I succesfully updated their allowances then I finally saw entries in the ASUS logs for connections.

Log entry from a succesful Putty connection
dropbear[16307]: Pubkey auth succeeded for ‘MyAdminName’ with key sha1!! Public:Derp:Key from 192.168.1.2:61615

Log entry of testing to SSH from Hassio without a user name defined
dropbear[31590]: Login attempt for nonexistent user from 192.168.1.2:57552

I’m wondering if the known_hosts for the container running HA doesn’t exist and it’s blocking it from ever actually making the calls to the ASUS router because I don’t get any log entries there at all that the HA is trying to connect.

I went looking in the asuswrt.py file and found the line that kicks out this specific error.

    try:
        if not self.connected:
            self.connect()
        self._ssh.sendline(command)
        self._ssh.prompt()
        lines = self._ssh.before.split(b'\n')[1:-1]
        return [line.decode('utf-8') for line in lines]

    except exceptions.EOF as err:
        _LOGGER.error("Connection refused. SSH enabled?")

The problem is the block is a bit large in the try code so it’s catching both the connection portion and then the attempt to send a command to it. I might try building a small Python app that connects to my Asus to see what’s happening with this code.

I’m using it with hassio and it’s been perfect, this is the config I use…

device_tracker:
  - platform: asuswrt
    host: 192.168.1.1
    username: XXXXXX
    password: XXXXXX
    consider_home: 30
    new_device_defaults:
      track_new_devices: False

I’ve seen a couple of reports of people having issues with 62.0 but those were using Telnet and that has apparently been fixed in 62.1.

What model & firmware are you on? I had seen other people mentioning having issues after moving to the newer 382 branch and I’m on the even newer 384 firmware branch from Asus.

I upgraded to 0.62.1 and I’m still having the same issue.

I’ll try the username/password option to see if it works since I’m using the PKI based method instead.

Using the username:password method I get a pile of failure errors at first but then it did start working. I believe I saw others report the same behavior on HA startup. I see active connections in my Asus log now from it which I never saw before.

[homeassistant.components.device_tracker.asuswrt] Unexpected SSH error: could not set shell prompt (received: b"unset PROMPT_COMMAND\r\nPS1='[PEXPECT]\$ ‘\r\nset prompt=’[PEXPECT]\$ '\r\n", expected: '\[PEXPECT\][\$\#] ').

So there’s either something broken with the SSH via PKI process or I’ve done something wrong. I did test my public/private key using Putty and they successfully worked there as well as from the core hassio SSH too.

I’m running a Netgear r7000 with AsusWRT Merlin so as far as anything’s concerned it’s an rt-ac86u, firmware is 380.69.

At 2023 year the asuswrt do not discover the devices - I see only 4 and there should be 70.

The way how it works for me is to install the community addon
https://asusrouter.vaskivskyi.com/guide/getting-started/#installation
and then I see all the devices sensors.