It was by chance. First, I started teaching English as a foreign language in Europe: that provided a useful background in pedagogy, although has nothing to do with computers. Second, I was offered an adjunct position at a university where I was a student, which gave me a taste of teaching CS.
You'll probably need at least a Master's degree if you want to teach, but a strong industry background might be enough. You might try approaching a local university (don't discriminate, even community colleges need teachers) about teaching one class a semester. If you like it, you can try a better school or go for a full-time position.