honssh icon indicating copy to clipboard operation
honssh copied to clipboard

Python 3 compatibility / porting.

Open robputt opened this issue 6 years ago • 5 comments

robputt avatar Mar 16 '18 10:03 robputt

Does Twisted Conch support Py3 now?

robputt avatar Mar 16 '18 10:03 robputt

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

robputt avatar Mar 16 '18 10:03 robputt

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?

robputt avatar Mar 16 '18 10:03 robputt

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

sturmf avatar Oct 15 '18 19:10 sturmf

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)
}

sturmf avatar Oct 15 '18 19:10 sturmf