Easy file sharing without Samba

This is a dialogue between co-workers:

A – Could you give me the discography of scorpions?
B – Of course!
A – Come on, share me the folder.

steve-ballmerThis phrase brings a shiver down my spine, because the average user sees the shared folders on windows the only way to exchange files. And I do not want to install samba. Look at him! Do you want to give your file to him?

I am a misanthrope, it’s known.

The alternative is not better, because it is based on the concept of traveling to the files for the entire globe, using services like Dropbox, when the person to whom I must give the precious discography is at the next desk.

But the answer is easy: FTP.

All desktop environments know how to use this secret protocol, but we need an ftp server. Those who have already installed an ftp server knows that pain on your back you get to create an optimal configuration.

Basically I look for a solution that:

  • It does not require root access.
  • The user can access only a chroot directory.
  • There is no need to create new users.

The answer?

PYTHON

You can use the pyftpdlib library:

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_anonymous('/home/kbyte/Music/Scorpions')

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(('*', 2121), handler)
server.serve_forever()

If you want to use a password-protected access, replace the sixth line with this:

authorizer.add_user('scorptionsfan', 'password', '/home/kbyte/Music/Scorptionsi', perm='elr')

😛 Happy sharing! 😛

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.