question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asyncssh 2.9.0 raises AttributeError: 'NoneType' object has no attribute 'encode' in know_hosts.py

See original GitHub issue

When I connect to realhost.host via asyncssh.create_connection(asyncssh.SSHClient, host='realhost.host') I get the following:

...
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 7977, in create_connection
    conn = await connect(host, port, client_factory=client_factory,
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 7646, in connect
    return await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 396, in _connect
    new_tunnel = await _open_tunnel(tunnel, options.passphrase)
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 375, in _open_tunnel
    return await connect(host, port, username=username,
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 7646, in connect
    return await asyncio.wait_for(
  File "/usr/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 439, in _connect
    await options.waiter
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 1216, in connection_made
    self._connection_made()
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 3105, in _connection_made
    self._match_known_hosts(cast(KnownHostsArg, self._known_hosts),
  File "/venv/lib/python3.8/site-packages/asyncssh/connection.py", line 1081, in _match_known_hosts
    match_known_hosts(known_hosts, host, addr, port)
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 374, in match_known_hosts
    known_hosts = known_hosts.match(host, addr, port)
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 275, in match
    x509_subjects, revoked_subjects = self._match(host, addr, port)
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 217, in _match
    matches += (match for (entry, match) in self._pattern_entries
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 218, in <genexpr>
    if entry.matches(host, addr, ip))
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 114, in matches
    return self._match(host) or self._match(addr)
  File "/venv/lib/python3.8/site-packages/asyncssh/known_hosts.py", line 108, in _match
    hosthash = hmac.new(self._salt, value.encode(), sha1).digest()
AttributeError: 'NoneType' object has no attribute 'encode'

Downgrating to 2.8.1 fixes the issue.

.ssh/config:

Host bastion.host
  ForwardAgent yes

Host realhost.host
  ProxyJump bastion.host

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ronfcommented, Mar 26, 2022

This change is now available in AsyncSSH 2.10.0.

1reaction
ronfcommented, Jan 26, 2022

Ok - the fix is now available as commit 018e013 in the “develop” branch. Thanks again for reporting it! If you have any further issues, please let me know…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve AttributeError: 'NoneType' object has no ...
Your s might be Nonetype. Try s = con.string if s:file.write(s.encode('utf8')) # or if s is not None #if you want to check...
Read more >
AttributeError: 'NoneType' object has no attribute 'encode' #120
According to #91 this was fixed in 1.9.94, but I am still seeing this (or similar) error message: Traceback (most recent call last):...
Read more >
AttributeError: NoneType object has no attribute 'encode'
The Python "AttributeError: 'NoneType' object has no attribute 'encode'" occurs when we try to call the encode() method on a None value, ...
Read more >
asyncssh - Bountysource
AsyncSSH is a Python package which provides an asynchronous client and server ... asyncssh 2.9.0 raises AttributeError: 'NoneType' object has no attribute ......
Read more >
AttributeError: 'NoneType' object has no attribute 'encode'
I cannot get my Github Secrets to pull into my main.py file. I built a workflow and the environmental variables pull correctly there...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found