<div>Not sure what you mean, but here is a basic example:</div><div><div><br></div><div>from zope.interface import implements</div><div><br></div><div>from twisted.application import service, internet</div><div>from twisted.conch.ssh.keys import Key</div>
<div>from twisted.conch.ssh.factory import SSHFactory</div><div>from twisted.conch.unix import UnixSSHRealm</div><div>from twisted.cred.checkers import ICredentialsChecker</div><div>from twisted.cred.credentials import IUsernamePassword</div>
<div>from twisted.cred.portal import Portal</div><div><br></div><div><br></div><div>def get_key(path):</div><div> return Key.fromString(data=open(path).read())</div><div><br></div><div><br></div><div>class DummyChecker(object):</div>
<div> credentialInterfaces = (IUsernamePassword,)</div><div> implements(ICredentialsChecker)</div><div><br></div><div> def requestAvatarId(self, credentials):</div><div> return credentials.username</div><div>
<br></div><div><br></div><div>def makeService():</div><div> public_key = get_key('id_rsa.pub')</div><div> private_key = get_key('id_rsa')</div><div><br></div><div> factory = SSHFactory()</div><div>
factory.privateKeys = {'ssh-rsa': private_key}</div><div> factory.publicKeys = {'ssh-rsa': public_key}</div><div> factory.portal = Portal(UnixSSHRealm())</div><div> factory.portal.registerChecker(DummyChecker())</div>
<div><br></div><div> return internet.TCPServer(2200, factory)</div><div><br></div><div><br></div><div>application = service.Application("sftp server")</div><div>sftp_server = makeService()</div><div>sftp_server.setServiceParent(application)</div>
</div><div><br></div><div><br></div><div>Put this content into a file like sftp.tac</div><div>The keys can be generated by ckeygen utility which is part of Twisted (e.g. ckeygen -b 2048 -t rsa -f id_rsa)</div><div>and run with twistd -ny sftp.tac</div>
<div><br></div><div>If you want more background on Twisted conch i suggest the "Twisted Conch in 60 Seconds" series by</div><div>Jean-Paul Calderone on his blog <a href="http://as.ynchrono.us/">http://as.ynchrono.us/</a></div>
<div><br></div><div>Michal Mach</div><div><br></div><br><div class="gmail_quote">On Mon, Aug 22, 2011 at 10:31 PM, Osborn Chan <span dir="ltr"><<a href="mailto:ychan@quova.com">ychan@quova.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Yes. It is SFTP, and I found that filetransfer.FileTransferServer is a<br>
subsystem under UnixConchUser.<br>
<br>
self.subsystemLookup.update({"sftp":<br>
filetransfer.FileTransferServer})<br>
<br>
However, I was able to start a ssh shell by using SSHFactory and<br>
UnixSSHReam, but I was not able to start SFTP as sub system.<br>
<br>
Do I need to do anything explicitly to start sftp subsystem?<br>
<br>
Thanks,<br>
<br>
-Osborn<br>
newbie in Python and Twisted.<br>
<div><div></div><div class="h5"><br>
<br>
On 8/22/11 12:50 PM, "Jasper St. Pierre" <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>> wrote:<br>
<br>
>What about twisted.conch.ssh.filetransfer? Is that not SFTP?<br>
><br>
>On Mon, Aug 22, 2011 at 3:36 PM, Drew Smathers <<a href="mailto:drew.smathers@gmail.com">drew.smathers@gmail.com</a>><br>
>wrote:<br>
>> On Fri, Aug 19, 2011 at 2:43 PM, Osborn Chan <<a href="mailto:ychan@quova.com">ychan@quova.com</a>> wrote:<br>
>>> Hi,<br>
>>><br>
>>> I am a newbie in twisted and python.<br>
>>> I would like to create a python SFTP server with twisted, but I cannot<br>
>>>find any sample.<br>
>>><br>
>>> Can someone give me some advise?<br>
>>><br>
>><br>
>> I don't believe there are any examples of building an SFTP server<br>
>> aimed at newcomers to twisted and python but there are existing<br>
>> implementations in the wild--which might honestly be difficult to<br>
>> digest if you don't know python well enough. I think zope at one time<br>
>> has SFTP server based on twisted (which I can't seem to summon with<br>
>> google) and there's also SFTP server implementation in tahoe-lafs<br>
>><br>
>>(<a href="https://github.com/warner/tahoe-lafs/blob/master/src/allmydata/frontends" target="_blank">https://github.com/warner/tahoe-lafs/blob/master/src/allmydata/frontends</a><br>
>>/sftpd.py).<br>
>><br>
>> -Drew<br>
>><br>
>> _______________________________________________<br>
>> Twisted-Python mailing list<br>
>> <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
>> <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
>><br>
><br>
><br>
><br>
>--<br>
> Jasper<br>
><br>
>_______________________________________________<br>
>Twisted-Python mailing list<br>
><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>