Manual SSH to AsusWrt works but HASS can't connect

I’m trying to configure the asuswrt component but when I restart HA the log shows the error “Connection refused. SSH enabled?”

I installed HA using the VirtualEnv instructions on Ubuntu 16.04. I’ve verified my router has SSH enabled. If I switch to the homeassistant user (the one created by following the VirtualEnv instructions) I can manually ssh to the router with no problems. I’ve tried setting SSH to listen on multiple ports on the router to make sure there weren’t any conflicts. I’ve tried using ssh key auth and just username / password. Nothing seems to make any difference.

When I manually ssh to the router, the system logs show the successful connection. Also, if I intentionally enter bad credentials the router system log shows the failed attempts. When HA shows the “Connection refused” error in the logs, the router system logs do not show anything. As far as I can tell there wasn’t any attempt by HA to connect to the router.

Anyone out there have any idea what else I can try?

A bit more information.

If I run this command on the HA box:

tcpdump -n port 22

and then restart HA no traffic is captured. As far as I can tell HA isn’t even trying to open an SSH session to the router. I know the tcpdump is working because if I manually open an ssh connection I see the traffic.

Same issue here. Any hint?

How do you start your HASS instance? Do you start it using a systemd script? If so, make sure you have the most recent version:

I also had some troubles. Previously, it was said that you should modify the ENV and PATH variable in the systemd script to ensure the virtual env is loaded. But apparently this is not needed. After I removed those, it worked for me.

I’ve used “Raspberry Pi All-In-One Installer” which create a script using systemd and I think is the most recent version, because HASS start at every boot without a problem.

How can i check it?

Run:
cat /etc/systemd/system/home-assistant.service
The file might be called a bit different. My output is this:

[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
#make sure the virtualenv python binary is used
#Environment=VIRTUAL_ENV="/srv/homeassistant" <-- I commented these and afterwards it worked
#Environment=PATH="$VIRTUAL_ENV/bin:$PATH" <-- I commented these and afterwards it worked
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

Afterwards reload with
sudo systemctl daemon-reload
And reboot. That fixed it for me.

That’s my version:

[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant/.homeassistant”

[Install]
WantedBy=multi-user.target

I see no differences (only the url for execStart that my depend fomr the script inside the AIO installer.

Too bad. For me that helped… Then your issue seems to be somewhere else.

Which version of the ASUS wrt are you running? I am running ASUS WRT Merlin v380.
Did you also try telnet instead of ssh?

gotcha!

Telnet works!

Should I need to leave user and psw or those fields are used only for ssh?

Thank you!

Telnet should be disabled on your router. There is no encryption, passwords are sent in the clear.

My service config doesn’t have those environment variables defined and never has. The service works fine, it just doesn’t connect to the router.

But telnet is the only way to make it works!

Telnet is accessible from external adresses?

I don’t know if your device is set up to be accessible from the Internet, Telnet just isn’t secure. If you don’t care then use it, but it is just asking for trouble.

The only way to get mine to work was to enable telnet and this is my code;

- platform: asuswrt
  host: 192.168.1.1
  username: admin
  password: !secret asus_password
  protocol: telnet
  interval_seconds: 30
  track_new_devices: false

I’m still experiencing this issue even after throwing away my entire installation and starting fresh. If I try to use telnet instead of SSH I get this message logged in the home-assistant.log file:

Socket exception [Errno -2] Name or service not known