I just sort of lucked into it. My first job out of college I worked for a professor who went on to start his own consulting firm. They hired me on and when I said I wanted to work as a contractor they were fine with it. I have to say it's a fantastic setup--if you get the chance to become self-employed, take it. The best part is never feeling guilty about being out of the office or taking off for extended periods.. in fact I've probably taken about 8 weeks of vacation so this year. Of course the downside is that vacation = unpaid leave but I find that the time is worth so much more than the money to me right now.
My job is kinda specialized, it has to do more with statistical programming and mathematical modeling than the coding that most people on HN do, so I guess that helps when it comes to trying to go it alone. To the extent that I'm qualified to dispense advice it would be to develop a specialized skill that your average competent hacker doesn't have, particularly if it involves a lot of math--a lot of good coders I come across know surprisingly little math. Most of the people I know who are successful consultants have such a background.