<div class="gmail_quote">
Hello,<br>
<br>
I have a python script that executes a python code on a remote host using SSH. It was working perfectly with Twisted 2.5. The method of returning private and public has changed in userauth.SSHUserAuthClient (Twisted 8.1).<br>
<br>
I was using (Twisted 2.5)<br>
------------------------------------------------<br>
def getPublicKey(self):<br>
return keys.getPublicKeyString(self.keyfile+'.pub')<br>
<br>
def getPrivateKey(self):<br>
return defer.succeed(keys.getPrivateKeyObject(self.keyfile))<br>
<br>
<br>
Now I am using (Twisted 8.1)<br>
----------------------------------------------------<br>
def getPublicKey(self):<br>
return keys.Key.fromFile(self.keyfile+'.pub')<br>
<br>
def getPrivateKey(self):<br>
return defer.succeed(keys.Key.fromFile(self.keyfile))<br>
<br>
and it doesn't work any more. I have attached the simplified script. Here is the scenario I am using and the exception I got. Any help is greatly appreciated.<br>
<br>
Scenario<br>
----------------------<br>
I am creating a DSA key using ssh-keygen (in Debian and Ubuntu) with
an empty password<br>
<br>
$ ssh-keygen -t dsa<br>
<br>
and copy it to my localhost<br>
<br>
$ ssh-copy-id -i ~/.ssh/id_dsa localhost<br>
<br>
then run the attached script, which tries to execute a python script remotely using SSH and get the following error<br>
<br>Traceback (most recent call last):<br> File "/usr/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite<br> why = getattr(selectable, method)()<br> File "/usr/lib/python2.5/site-packages/twisted/internet/tcp.py", line 362, in doRead<br>
return self.protocol.dataReceived(data)<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py", line 314, in dataReceived<br> self.dispatchMessage(messageNum, packet[1:])<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py", line 336, in dispatchMessage<br>
messageNum, payload)<br>--- <exception caught here> ---<br> File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 51, in callWithLogger<br> return callWithContext({"system": lp}, func, *args, **kw)<br>
File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 36, in callWithContext<br> return context.call({ILogContext: newCtx}, func, *args, **kw)<br> File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext<br>
return self.currentContext().callWithContext(ctx, func, *args, **kw)<br> File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext<br> return func(*args,**kw)<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/service.py", line 44, in packetReceived<br>
return f(packet)<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py", line 262, in ssh_USERAUTH_FAILURE<br> if method not in self.authenticatedWith and self.tryAuth(method):<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py", line 234, in tryAuth<br>
return f()<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py", line 338, in auth_publickey<br> keyType = getNS(publicKey)[0]<br> File "/usr/lib/python2.5/site-packages/twisted/conch/ssh/common.py", line 51, in getNS<br>
l, = struct.unpack('!L',s[c:c+4])<br>exceptions.TypeError: 'Key' object is unsubscriptable<br><br>
Sincerely<br>
<br>
Saki<br>
</div><br>