Technical Blog

Singpolyma

Technical Blog

Archive for the “Tech” Category

Anonymous SFTP on Ubuntu

Posted on

I spent some time today getting anonymous SFTP setup on my home server. Why would I want to do that, you ask? Well, for file shares. I have an HTTP server and anonymous FTP server set up to make it easier for people to get at the public shares on the system, but really I'm a big fan of consolidating the protocols in this space. FTP is old and clunky, SFTP has solved many of the issues and is widely deployed. In fact, all my PCs are running an SFTP server, only one currently runs an FTP server.

This how-to uses the command line. It's really not that hard, just type exactly what I tell you to.

First, make sure you have the SSH server installed:

sudo apt-get install openssh-server

Next, create a new user:

sudo adduser --disabled-password anonymous

Then, edit the /etc/shadow file to make the password actually empty:

sudo ${EDITOR=gedit} /etc/shadow

Go to the last line and change the anonymous:*: to anonymous::

Edit /etc/passwd to make the empty password allowed and the login shell is set to /usr/lib/sftp-server

sudo ${EDITOR=gedit} /etc/passwd

Go to the last line and change anonymous:x: to anonymous:: and also change the value on the end of the line (it will either be /bin/bash or /bin/sh) to /usr/lib/sftp-server.

Next, you need to allow sftp-server as a valid shell.

sudo su
echo /usr/lib/sftp-server >> /etc/shells
exit

You also need to allow PAM to accept blank passwords for SSH sessions, so:

sudo ${EDITOR=gedit} /etc/pam.d/sshd

Change the line that reads @include common-auth and replace it with:

auth [success=1 default=ignore] pam_unix.so nullok
auth requisite pam_deny.so
auth required pam_permit.so

Finally, you need to set the SSH server to allow blank passwords.

sudo ${EDITOR=gedit} /etc/ssh/sshd_config

Find the line that reads PermitEmptyPasswords no and change the no to a yes.

Restart sshd with:

sudo /etc/init.d/ssh restart

And you're done!

Warning: make sure the anonymous user does not have access to files you do not want it anyone to have access to! Ubuntu by default makes way too many things world-readable. This how-to is not about file permissions, but make sure your private files are set so that only your user can read them!

Simple HTTP-based File Shares for Ubuntu

Posted on

This is a simple how-to for setting up automatic file sharing for users' ~/Public folders in Ubuntu over HTTP with minimal overhead.

While this how-to is simple, it does use the command line. I happen to believe the command line is not so scary as the GUI marketing people would have you think, even to new users. It's much easier to say "type this" and have a user understand than it is to try to describe the GUI actions.

First, install my subdirs script. This script finds a list of directories containing some other directory, and prints out the path to the subdirectory (if you don't get that, never mind, you just need to know that you need in installed for this how-to).

sudo wget -O /usr/local/bin/subdirs http://github.com/singpolyma/singpolyma/raw/master/scripts/subdirs
sudo chmod +X /usr/local/bin/subdirs

Then, install the webfs HTTP server.

sudo apt-get install webfs

Edit the config file a bit:

sudo ${EDITOR=gedit} /etc/webfsd.conf

Change the line starting with web_root= to say:

web_root=/var/www

And the line starting with web_port= to say:

web_port=80

Then restart the server by running:

sudo /etc/init.d/webfs restart

Finally, to symlink the shares, run:

subdirs /home Public | while read DIR; do ln -s "$DIR" /var/www/$(basename "`dirname "$DIR"`"); done

You're done!

The last command will have to be re-run every time you add a new user. Or you could add it as the second-last line in your /etc/rc.local file to make it run every time you boot.

Now people can just visit your computer in their webbrowser (if they're on your local network… to get access from the Internet you have to configure your router, but you probably don't want that anyway). The address of any Ubuntu computer in a webbrowser (on a computer than supports mDNS, such as other Ubuntu systems or Apple systems) is just hostname.local. For example, my computer is singpolyma-mini.local. For Windows users, they'll have to type in your IP address (unless they install Bonjour for Windows).

You can find your IP address by running:

ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | awk '{ print $2 }'

PostRank "Buckets"

Posted on

After an incredible amount of time working with, and for, PostRank, I think I have finally landed on what I would like to do with their technology that would be useful to me.

Back when I was working a lot on their Google Reader Greasemonkey overlay, one of the features requested was "sort by PostRank", which never made a lot of sense to me. Sort what by PostRank?

Buckets.

I want to read basically everything that comes through my feedreader, or at least see the headlines, but I may not care about it all at this moment. I don't want an interestingness sort or filter, I want a bucketizer. I want to be able to say "I'll read the best stuff right now when I've got a few seconds, and the rest later."

I may never read the rest, which then amounts to filtering, but I may, and that's different.

The best way to implement something like this would be to allow for "filtering" by PostRank ranges instead of having a max cutoff. That way I could have a 7+ feed, a 3-7 feed, and a 3- feed, for each feed. I'd then make (in my reader) a "Best" folder, a "Good" folder, and a "Bottomfeeder" folder. I'd process the content in "Best" a few times a day, "Good" at least once a week, "Bottomfeeder" whenever I had extra time to read stuff.

I actually really like this idea. A lot.

DiSo Dashboards and the Future

Posted on

So, finally someone talking about the future of distributed social networking. The tech and the connecty bits we want have really been mostly there for some time now, the problem is, no one has been very clear on what the next step is. Chris Messina has been a bit distracted with the Activity Streams project, and no one else has really been saying much about DiSo.

The next step, however, is really coherent UI. I've been talking about it off and on as my "ultimate aggregator", Marc Canter is calling it "dashboards".

One of the things he talks about in the presentation is "distributed friending". This is something I've brought up before. IMHO, the best way to go about this is to have magical buttons that, when clicked, take the user to their "dashboard" with the target's URI (or one of them, anyway) already filled in. At that point, you have an asynchronous friending model. The local software can then do different things (like permissions, autofilling searches, pulling in content, just making the list available to other services than then do these things, whatever) based on this data, but no magical "protocol" or anything is needed, because with an asynchronous model all you're really doing is making a note of the relationship in a data model and letting the software use that list for whatever.

Past integrating the posting/following/aggregation UI a bit more, I'm not really sure there's anything left, conceptually. I'd like to dig up some code and make OAuth+AtomPub work for sure with the newest version (so that any aggregator can talk to my WP blog :) ), and code can always be improved, but really, what is a social network? It's an aggregator of sorts, a posting mechanism of sorts, and email. We've had the later two for ages, which is why so much work has been dancing around the first one.

BitTorrent Monitization Proposal

Posted on

There are lots of "monitize p2p" proposals floating around out there. Most of them look like a levy. The problem with this model is that, using existing p2p networks, there is no particularly good way to know what music is popular, and thus, who gets the money. Also, since some will download far more than others, and there's no good way to measure how much anyone should pay.

The solution from the private sector so far looks like the Amazon MP3 store or Apple's iTunes. Much less content, in fewer formats. The big argument from media is that online distribution is a hard problem one that will take research to solve. However, we know quite well that the p2p networks, and especially BitTorrent, have solved this problem.

My proposal? Marry the distribution power of BitTorrent with a sales model. Create a modified tracker that requires authentication. Seed high-quality versions of movies, music, books, and everything on this tracker. Set prices per download/sample and/or membership plans (10 ¤/mo for 3 movies/mo). People have to either have money on their account, a PayPal/credit card associated, or be on some kind of plan, otherwise the tracker refuses them service.

The big media from the big companies gets seeded, and people get it and pay for it. All the old media, small media, etc that becomes available through p2p still shows up as users connect to the network and start seeding stuff, but it too gets paid for, with the money routed to the right people.

Some will argue that there are those who will still pirate if such a system should exist. Of course there will. There will always be those who justify breaking the law. I'm talking about giving people a better option, which right now they don't really have.