Opened 16 years ago

Closed 11 years ago

#1975 enhancement closed wontfix (wontfix)

connectSSH utility method / function for connecting places with conch

Reported by: Glyph Owned by:
Priority: normal Milestone:
Component: conch Keywords: soc2007
Cc: z3p Branch:


I'd really like to be able to write a tool which would spawn a remote process using SSH and communicate via a regular protocol.

Something like this would be neat:

class FileWriter(Protocol):
    def __init__(self, openable):
        self.openable = openable
    def connectionMade(self):
        self.file ="wb")
    def dataReceived(self, data):
    def connectionLost(self):
    "glyph", "", ["tar", "cvjf", "-", "files-to-back-up"],

(although perhaps the right API would be to take a client protocol factory instead)

Change History (7)

comment:1 Changed 16 years ago by Jean-Paul Calderone

  • connectSSH should be a method on a connection manager object
  • The 3rd and 4th arguments should be composed into a single object
    • it needs to know to request a command channel (currently not indicated anywhere)
    • it needs to know the command to execute (the 3rd argument)
    • it needs to know where to send stdout and stderr (kind of the 4th argument)
  • The ProcessProtocol/Protocol hookup should not be implicit
    • explicitly connect them with one of several provided helpers with different policies
      • discard stderr
      • log stderr
      • signal failure on stderr
      • collapse stderr into stdout
      • etc
    • maybe have a default adapter from IProtocol to IProcessProtocol which does the most obnoxious, safe thing (not specific to ssh - this would be a general purpose adapter in Twisted)
      • issues of whether to register it unconditionally
      • issues of where to register it from (someplace that will _always_ be imported)
        • not twisted/
        • not components.wsv

comment:2 Changed 15 years ago by z3p

Cc: z3p added
Owner: changed from radix to z3p

I'll be working on this as part of GSoC.

comment:3 Changed 15 years ago by z3p

Keywords: soc2007 added
Status: newassigned

comment:4 Changed 13 years ago by radix

No, I don't think connectSSH should involve a *command*, or make any assumptions about using the shell or exec channels: I think it should take a channel name and an IProtocol provider. There should also be something like listenSSH which takes a channel and a protocol.

Maybe there should be something that actually hooks up a protocol to a command, but that should be called something like connectSSHCommand, or whatever.

comment:5 Changed 13 years ago by Glyph

Given that this is a utility method, I actually don't give a crap about channels, subsystems, or whatever. The use-case I have is that I want it to be easy to connect to OpenSSH servers and either do some common shell thing (c.f. the tar example) or bootstrap a connection to another Twisted process running on that host.

Tools like bzr and svn, for example, don't really care what ssh is doing, as long as they're talking to another instance of themselves on the other end.

The suggestions here are probably good for internally factoring this interface. Maybe we need an intermediary layer, or maybe all these other objects can be conveniently provided in some way. However, we should not lose sight of the fact that the whole point of this ticket is to provide a convenient, easy-to-understand API for the rather large audience of people who have no idea what the guts of the SSH protocol look like, and whose only experience of it is the OpenSSH command line. If the documentation for this method contains the word "channel" anywhere, I would consider it a failure.

(I think my understanding of the way SSH deals with commands was flawed though; that list should probably have just been a string.)

comment:6 Changed 11 years ago by <automation>

Owner: z3p deleted

comment:7 Changed 11 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: assignedclosed

Endpoints are how we've decided to expose this functionality. The endpoint ticket for a remote SSH command is #4698.

Note: See TracTickets for help on using tickets.