Asuswrt device tracker not working with ssh login

For the love of god I cannot get asuswrt working on my RT-68 router running normal firmware.

THis is my configuration in config.yaml file. I can successfully login to router using putty and the certificate via ssh. I have no passphrase set for the certificate. Anyone can help???

Config.yaml

asuswrt:
  host: 192.168.1.1
  username: test123
  ssh_key: /config/ssh/privatenopass

Configuration of device_tracker.yaml

- platform: asuswrt
  host: 192.168.1.1
  username: test123
  ssh_key: /config/ssh/privatenopass

This is what i get as an error.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 168, in _async_setup_component
    hass, processed_config
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/__init__.py", line 71, in async_setup
    await api.connection.async_connect()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/connection.py", line 72, in async_connect
    self._client = await asyncssh.connect(self._host, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/misc.py", line 182, in __await__
    return (yield from self._coro)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/connection.py", line 5451, in connect
    conn, _ = yield from create_connection(None, host, port, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/connection.py", line 5070, in create_connection
    client_keys = load_keypairs(client_keys, passphrase)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/public_key.py", line 2965, in load_keypairs
    key, certs = read_private_key_and_certs(key, passphrase)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/public_key.py", line 2694, in read_private_key_and_certs
    key, cert = import_private_key_and_certs(f.read(), passphrase)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/public_key.py", line 2545, in import_private_key_and_certs
    key, end = _decode_der_private(data, passphrase)
  File "/usr/local/lib/python3.7/site-packages/asyncssh/public_key.py", line 2087, in _decode_der_private
    raise KeyImportError('Invalid DER private key')
asyncssh.public_key.KeyImportError: Invalid DER private key
1 Like

How did you generate /config/ssh/privatenopass? With putty? If so, you probably need to export it. Putty doesn’t generate keys in a format that’s usable by openssh. It works with putty because the format it gives you for the public key (which you installed on the router) is compatible.

Also, please note that ssh doesn’t work with certificates – it works with public and private keys. In the PKI world, a certificate usually contains a public key, and never a private key. The private key would be stored separately, although sometimes in the same file (which tends to confuse people). :slight_smile:

3 Likes

I did it with puttygen.

So if I understand right i have to convert the private key as an openssh key *using puttygen)?

That is correct.