kennedyshead / aioasuswrt

MIT License
24 stars 24 forks source link

ERROR: Unable to complete integration setup: Passphrase must be specified to import encrypted private keys #89

Open ntsiro opened 1 year ago

ntsiro commented 1 year ago

Trying to setup the ASUSWRT integration using SSH to authenticate, I am running into the below error:

`Logger: homeassistant.components.asuswrt.config_flow Source: components/asuswrt/config_flow.py:155 Integration: ASUSWRT (documentation, issues) First occurred: 7:30:30 PM (4 occurrences) Last logged: 8:09:00 PM

Unknown error connecting with AsusWrt router at 192.168.50.1 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/asuswrt/config_flow.py", line 155, in _async_check_connection await api.connection.async_connect() File "/usr/local/lib/python3.10/site-packages/aioasuswrt/connection.py", line 78, in async_connect self._client = await asyncssh.connect(self._host, *kwargs) File "/usr/local/lib/python3.10/site-packages/asyncssh/connection.py", line 8037, in connect new_options = cast(SSHClientConnectionOptions, await _run_in_executor( File "/usr/local/lib/python3.10/site-packages/asyncssh/connection.py", line 515, in _run_in_executor return await loop.run_in_executor( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/asyncssh/connection.py", line 6423, in init super().init(options=options, last_config=last_config, kwargs) File "/usr/local/lib/python3.10/site-packages/asyncssh/misc.py", line 350, in init self.prepare(**self.kwargs) File "/usr/local/lib/python3.10/site-packages/asyncssh/connection.py", line 7282, in prepare load_keypairs(cast(KeyPairListArg, client_keys), passphrase, File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 3470, in load_keypairs read_private_key_and_certs(key_to_load, passphrase) File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 3284, in read_private_key_and_certs key, cert = import_private_key_and_certs(read_file(filename), passphrase) File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 3157, in import_private_key_and_certs key, end = _decode_private(data, passphrase) File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 2761, in _decode_private key = _decode_pem_private(pem_name, headers, data, passphrase) File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 2672, in _decode_pem_private return _decode_openssh_private(data, passphrase) File "/usr/local/lib/python3.10/site-packages/asyncssh/public_key.py", line 2509, in _decode_openssh_private raise KeyImportError('Passphrase must be specified to import ' asyncssh.public_key.KeyImportError: Passphrase must be specified to import encrypted private keys`

Note that the same SSH connection is working fine when connecting from my macOs terminal - SSH config as below

Host router HostName 192.168.50.1 User admin Port 1025 IdentityFile ~/.ssh/id_rsa

Settings I am trying on ASUSWRT integration wizard:

Screenshot 2023-05-09 at 20 08 58
ntsiro commented 1 year ago

also note that I have confirmed that the SSH connection with the same parameters works from within home assistant ssh session to the router.

ntsiro commented 1 year ago

I should also add that I have added the private key to the home assistant ssh-agent with ssh-add, so when manually establishing an ssh session I don't get prompted for they key passphrase no more.