2 John 1:12
Do we receive people or not? (Galatians 6:10 vs 2 John 10-12)
2 John 10-12 is made in response to false teachers. It should be added that by welcoming false teachers, especially those who (as John indicates) have perverted the true message, one does more harm than good, so that it would be adequate to say that the only real "opportunity" to do good is to rebuff the false teachers, lest they harm others.
Note that Paul says, "As we have opportunity...", the word being kairos referring to an occasion, or a set and proper time. This situation would not offer an "opportunity" to do good unto all men precisely because it would do more harm than good.
Beyond that, within the social context of 2 John, the reference is not to giving someone who is homeless a place to stay, but to giving an itinerant teacher a central headquarters from which to distribute his teaching. It is not as though they need someplace to stay and that one can do "good" by being charitable to them.