<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(&#39;id_rsa.pub&#39;)</div><div>    private_key = get_key(&#39;id_rsa&#39;)</div><div><br></div><div>    factory = SSHFactory()</div><div>
    factory.privateKeys = {&#39;ssh-rsa&#39;: private_key}</div><div>    factory.publicKeys = {&#39;ssh-rsa&#39;: 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(&quot;sftp server&quot;)</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 &quot;Twisted Conch in 60 Seconds&quot; 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">&lt;<a href="mailto:ychan@quova.com">ychan@quova.com</a>&gt;</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({&quot;sftp&quot;:<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, &quot;Jasper St. Pierre&quot; &lt;<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>&gt; wrote:<br>
<br>
&gt;What about twisted.conch.ssh.filetransfer? Is that not SFTP?<br>
&gt;<br>
&gt;On Mon, Aug 22, 2011 at 3:36 PM, Drew Smathers &lt;<a href="mailto:drew.smathers@gmail.com">drew.smathers@gmail.com</a>&gt;<br>
&gt;wrote:<br>
&gt;&gt; On Fri, Aug 19, 2011 at 2:43 PM, Osborn Chan &lt;<a href="mailto:ychan@quova.com">ychan@quova.com</a>&gt; wrote:<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am a newbie in twisted and python.<br>
&gt;&gt;&gt; I would like to create a python SFTP server with twisted, but I cannot<br>
&gt;&gt;&gt;find any sample.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Can someone give me some advise?<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I don&#39;t believe there are any examples of building an SFTP server<br>
&gt;&gt; aimed at newcomers to twisted and python but there are existing<br>
&gt;&gt; implementations in the wild--which might honestly be difficult to<br>
&gt;&gt; digest if you don&#39;t know python well enough. I think zope at one time<br>
&gt;&gt; has SFTP server based on twisted (which I can&#39;t seem to summon with<br>
&gt;&gt; google) and there&#39;s also SFTP server implementation in tahoe-lafs<br>
&gt;&gt;<br>
&gt;&gt;(<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>
&gt;&gt;/sftpd.py).<br>
&gt;&gt;<br>
&gt;&gt; -Drew<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Twisted-Python mailing list<br>
&gt;&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt;&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;--<br>
&gt;  Jasper<br>
&gt;<br>
&gt;_______________________________________________<br>
&gt;Twisted-Python mailing list<br>
&gt;<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt;<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>