I've successfully worked from home as a developer since 2001, most of which was in a 450 square foot apartment with roommates in a very noisy part of Brooklyn. Now I'm in a far more comfortable 2 bedroom with a view in Seattle with a separate bedroom as an office (and a door!), but my career was defined in that tiny shoebox of apartment.

First and foremost, boundaries are necessary. This is both for you and for the people around you. You don't have to explicitly work 8 hours in a row every day, but whenever it is that you choose to work every day, disruptions should be completely closed off.

This means if you have roommates, they need to know that when you're working, you're not listening and impossible to distract. For me, this has proven far more difficult with significant others who have lived with me. I have lost a couple long term relationships with women who did not understand this, and the woman with whom I'm now engaged not only appreciates this this very important invisible wall, but helps me maintain it.

Same goes for other outside distractions. It would be weird if your friends dropped into your 9-5 job and sat on the couch, cracked a beer and started playing video games, or if they called your office line every 20 minutes to try to convince you to head out for whatever might be going on. This same limitation needs to be set at your home. If necessary, maintain a separate lines of communication between work and personal life (phone, IM, skype, email, etc) to make sure that while you're working, you can concentrate on only communicating with work associates, and the opposite is just as important - when you're enjoying your life, leave work to your office space.

And if your home office is in a distracting neighborhood (as mine very much was when I was living in Brooklyn), turn some music on, wear some headphones, find a coffee shop, or rent some office space somewhere quieter. Depending on where you are, it's not difficult to find a company that happens to have an extra desk or two and is willing to rent one out at a fair price.

Give yourself a great office space that you look forward to spending your days in. Mine was a corner of a room that was sometimes also a bedroom and sometimes also a living room. But it was the most well kept at all times. Three monitors, a quiet and fast computer, a comfortable chair, interesting art on my wall, a great keyboard and mouse, a relatively clean desk, a decent coffee maker, great stereo system, studio-quality headphones, high speed expensive internet, and a giant roll of paper with some markers that I could brainstorm or play with whenever necessary.

I've read some other great responses here about exercise, and eating right and so on. I agree with all of the above, but I didn't bother with such things until the past 5 years. I never exercised, I worked stupidly long hours (occasionally 36 hour days), I ate crap, I partied at all hours, and I'd never set a schedule. I began changing a lot of that in the past five years or so. I now limit myself to 16 hours in a day (but usually keep my limit to 8) and I exercise more and I eat better. But I do those things because I turned 30 and realized 9 years of random debauchery and no exercise do not do much for ones health and figure. I'd be a liar if I told you I did that during the most crucially defining portion of my remote career.

As for the Real Motivation. All of the above and all the advice in this thread, and all the advice I've read elsewhere (and mostly ignored) about remote working have no competition with this one single point. What has motivated me more than anything in the world: Challenging Work at High wages. I always needed at least one of the two or the project would definitely fail, but having both ensured that I'd always find the time, energy, and space to get the work done well, efficiently, with great communication. The office space didn't matter. The noise didn't matter. The schedule _Definitely_ didn't matter. I was unstoppable provided I had Work that I couldn't possibly tear myself away from and a sizable check at the starting and finish lines to help keep my life in order.

Good luck.