[Twisted-Python] ssh client and server

cyli at alum.mit.edu cyli at alum.mit.edu
Fri Apr 11 11:50:29 EDT 2008


If I understand you correctly, you want a shelless SSH server but one 
that executes commands.  For instance, it will accept the following 
connection:

ssh server "echo Hello!"

But not:

ssh server

Is this correct?  I'm did something similar, except that I also reject 
the first type of command.  What I did was to overwrite 
session.SSHSession's request_shell command to terminate the connection 
instead of returning a shell.    And then of course I subclassed 
ConchUser to return my own session (rather than session.SSHSession) for 
the channelLookup, and wrote my own realm that returned my user from 
requestAvatar.

There may be a better way to do it, but this is short, and it works. I 
stuck my code up here in case you want to look at it: 
http://cyli.livejournal.com/38382.html


On 03:08 pm, vvangelovski at gmail.com wrote:
>I did look at that too. In and Ideal situation I'd make a server that 
>responds to exec from the client, generates a response for the command 
>and sends it back to the client, then drops the connection. But I can't 
>find a way to do that.
>
>Kuba Konczyk wrote:
>>Have a look at 
>>http://twistedmatrix.com/trac/browser/trunk/doc/conch/examples/sshsimpleserver.py
>>
>>2008/4/11, Vasil Vangelovski <vvangelovski at gmail.com>:
>>>I want to write a custom ssh server and client. the client should
>>>  authenticate, execute just one command on the server and get back 
>>>the
>>>  response. I've been following the examples from the O'reilly book, 
>>>but
>>>  I'm kinda lost. Basicaly what I wand to do is use the client from 
>>>the
>>>  last example, but a simpler server without a terminal emulator,
>>>  nothing fancy. Can anyone help?
>>
>>_______________________________________________
>>Twisted-Python mailing list
>>Twisted-Python at twistedmatrix.com
>>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




More information about the Twisted-Python mailing list