<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>
 &nbsp; return keys.getPublicKeyString(self.keyfile+&#39;.pub&#39;)<br>
<br>
def getPrivateKey(self):<br>
 &nbsp; return defer.succeed(keys.getPrivateKeyObject(self.keyfile))<br>
<br>
<br>
Now I am using (Twisted 8.1)<br>
----------------------------------------------------<br>
def getPublicKey(self):<br>
 &nbsp; return keys.Key.fromFile(self.keyfile+&#39;.pub&#39;)<br>
<br>
def getPrivateKey(self):<br>
 &nbsp; return defer.succeed(keys.Key.fromFile(self.keyfile))<br>
<br>
and it doesn&#39;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>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/internet/selectreactor.py&quot;, line 146, in _doReadOrWrite<br>&nbsp;&nbsp;&nbsp; why = getattr(selectable, method)()<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/internet/tcp.py&quot;, line 362, in doRead<br>
&nbsp;&nbsp;&nbsp; return self.protocol.dataReceived(data)<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py&quot;, line 314, in dataReceived<br>&nbsp;&nbsp;&nbsp; self.dispatchMessage(messageNum, packet[1:])<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/transport.py&quot;, line 336, in dispatchMessage<br>
&nbsp;&nbsp;&nbsp; messageNum, payload)<br>--- &lt;exception caught here&gt; ---<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/python/log.py&quot;, line 51, in callWithLogger<br>&nbsp;&nbsp;&nbsp; return callWithContext({&quot;system&quot;: lp}, func, *args, **kw)<br>
&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/python/log.py&quot;, line 36, in callWithContext<br>&nbsp;&nbsp;&nbsp; return context.call({ILogContext: newCtx}, func, *args, **kw)<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/python/context.py&quot;, line 59, in callWithContext<br>
&nbsp;&nbsp;&nbsp; return self.currentContext().callWithContext(ctx, func, *args, **kw)<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/python/context.py&quot;, line 37, in callWithContext<br>&nbsp;&nbsp;&nbsp; return func(*args,**kw)<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/service.py&quot;, line 44, in packetReceived<br>
&nbsp;&nbsp;&nbsp; return f(packet)<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py&quot;, line 262, in ssh_USERAUTH_FAILURE<br>&nbsp;&nbsp;&nbsp; if method not in self.authenticatedWith and self.tryAuth(method):<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py&quot;, line 234, in tryAuth<br>
&nbsp;&nbsp;&nbsp; return f()<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/userauth.py&quot;, line 338, in auth_publickey<br>&nbsp;&nbsp;&nbsp; keyType = getNS(publicKey)[0]<br>&nbsp; File &quot;/usr/lib/python2.5/site-packages/twisted/conch/ssh/common.py&quot;, line 51, in getNS<br>
&nbsp;&nbsp;&nbsp; l, = struct.unpack(&#39;!L&#39;,s[c:c+4])<br>exceptions.TypeError: &#39;Key&#39; object is unsubscriptable<br><br>
Sincerely<br>
<br>
Saki<br>
</div><br>