Here's the deal: free hydrogen (H2) is reduced relatively by easily by O2 producing energy and water, so if there were any free hydrogen on earth, we could reduce it with oxygen which is readily available in the atmosphere. The problem is, there isn't any free hydrogen, because the earth's gravity is so weak and the mean free path of hydrogen (distance that hydrogen can zip around in the atmosphere without hitting any other molecules) is so long that all free hydrogen in the earth's atmosphere has already been reduced into water or hydrides in the earth's crust or has escaped into space.
That means that, yes, if you want to use hydrogen you have to produce it, which as you correctly surmised means it has to be made available through electrolysis. The energy for electrolysis has to come from existing energy sources. H2 is freed from oxygen, stored, and then recombined in a fuel cell with O2, releasing no more energy than that which was used to separate it in the first place.
That's why I say hydrogen isn't an energy source, but a storage medium. Given how dangerous hydrogen is to transport and store, it's not clear that it's superior to the methods already used. And for those concerned about such things (many people--of whom I am not one) water vapor is a greenhouse gas.