tnich/honssh

Python 3 compatibility / porting.

robputt opened this issue · 5 comments

Python 3 compatibility / porting.

Does Twisted Conch support Py3 now?

Last upstream commit seems to be from 14th September 2016, is Twisted dead?

Seems Twisted Conch is not yet Py3 capable...

2018-03-16 10:25:52+0000 [twisted.conch.ssh.factory.SSHFactory] Unhandled Error
Traceback (most recent call last):
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/internet/selectreactor.py", line 149, in _doReadOrWrite
why = getattr(selectable, method)()
--- ---
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/internet/tcp.py", line 1073, in doRead
protocol.makeConnection(transport)
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/internet/protocol.py", line 510, in makeConnection
self.connectionMade()
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/conch/ssh/transport.py", line 543, in connectionMade
self.sendKexInit()
File "/Users/robe8437/Documents/Python/envs/general_dev/lib/python3.6/site-packages/twisted/conch/ssh/transport.py", line 565, in sendKexInit
NS(b','.join(self.supportedPublicKeys)),
builtins.TypeError: sequence item 0: expected a bytes-like object, str found

Maybe we can subclass it and override methods that require updating? < @tnich @Bifrozt @bang-uin thoughts?

Any news on this, I get this with Twisted 18.7.0 and Python3.

Ok I stand corrected it does work!
But now you have to prefix a lot of the strings with b for a byte array. E.g. the key looks now like this:

publicKeys = {
    b'ssh-rsa': keys.Key.fromString(data=sshkeys.SERVER_PUBLIC_KEY)
}