06 December 2010

Easier Personal File Sharing in Ubuntu

I don't know why it's so hard to get file sharing right in Ubuntu Linux [1] (Mac OS X makes it so easy).  But now there's a way for easy personal file sharing in Ubuntu.  This is meant for you sharing files with, basically, yourself, or at most one or two other people who you don't mind letting use your computer (ie, you don't mind making them an account on your computer to log in with).  If you need file sharing that's more complicated than that, you better find a more comprehensive solution, using Samba, or whatever else.

My solution basically boils down to using SSH to do the network connections, a fire wall to control whether to allow sharing of files or not at any time, user accounts to control who can log in to get at shared files, and SFTP on connecting computers to access the shared files in your Ubuntu Linux computer.  This means that you can't just share any single folder, but must share everything in a single home directory, or else you'll have to do some file permissions judo (but if you must do that, then you might as well get a proper file sharing service going).

On your Ubuntu computer, using the Synaptic package manager or Ubuntu Software Center, install sshd and a fire wall control program (I can suggest Firestarter and Firewall configuration).

sshd seems to configure itself just fine, so you just need to configure your firewall.  The pertinent part about your firewall is setting up a rule to allow access from certain IPs to your computer's port 22.  I allow every computer in my subnet 192.168.0.x to access my files, so I have a rule allowing (the 24 shows that the first 24 bits are subnet masked) to access my computer's port 22.

If you only want to allow yourself access to your home folder's files, you're already set up!  This was my own use case (just wanting to share my own files with myself on multiple computers).  If others who don't have an account of your computer wants to be able to access files on your computer, you will have to create a user account for them on your computer, and do some folder permission judo, or else copy those files to that user's home folder, to let them get access to them.

In any case, so now, on another computer, you can SFTP into the first computer (where you installed sshd) using the IP address of that computer.  If you use Ubuntu on this second computer, you can do this in Nautilus (just type in the address bar sftp://your_user_name@ip.address.right.here).  If you're on Windows, you can use Filezilla as a SFTP program.  I don't recall which program Macs can use, but there's certainly one.

And that's it!  When you want to "shut down" file sharing, just close down the firewall rule.

[1] I've tried both the File Sharing and Personal File Sharing packages in Ubuntu.  They were more hassle and unreliable than I cared for in my extremely simple use-case.

No comments: