There is a dispute as to the nature of the obligation to light Chanukah candles. It is clear that the candles must be lit in a house. That being the case, though, must someone without a house light them?
The Gemara (Shabbos 21b) says that the mitzvah to light Chanukah candles applies to a man and his household, “beiso.” The Rambam (Hilchos Chanukah 4:1) writes that the mitzvah is to have a candle lit in each house. Both these statements imply that if a person does not have a house, he is exempt from the mitzvah.
The Chachamim instituted that someone who sees a Chanukah candle, and does not intend on lighting himself that night for whatever reason, should recite the berachah of She’asa Nissim. Tosafos (on Sukkah 46a) asks why don’t we find an obligation to recite such a berachah for any other mitzvah. One of Tosafos’s answers is that the mitzvah to light Chanukah candles requires having a house, and since many people do not have a house, a berachah was instituted to include them in the mitzvah.
Tosafos points out that this answer is not fully satisfactory since there are other mitzvos, such as affixing a mezuzah, that require having a house. Why, then, did Chazal not institute a special berachah upon seeing a mezuzah in order to include people who do not have homes in this mitzvah?
Regardless of the answer to this objection, it is clear from Tosafos’s comments concerning She’asa Nissim that Tosafos, too, believes that the mitzvah of lighting Chanukah candles only applies to someone with a home.
Although we mentioned that the Rambam seems to holds this position as well, he gives the opposite impression – that everyone must fulfill this mitzvah, even those without a home – in Hilchos Berachos (11:2, 3) where he divides the biblical mitzvos into those one must fulfill and those one must fulfill only if certain conditions are met. Tefillin, lulav, and shofar fall in the first category while mezuzah and ma’akeh (building a fence around a roof) fall in the second. (A person is not obligated to have a house in order to affix a mezuzah or build a ma’akeh.) The Rambam then divides the rabbinic mitzvos into the same two categories. Megillah and lighting Shabbos and Chanukah candles fall in the first category, he writes, and eiruv and netilas yadayim fall into the second.
By placing the mitzvah of lighting Chanukah candles in the first category, the Rambam seems to be suggesting clearly that everyone must endeavor to light Chanukah candles, and if someone doesn’t have a home, he must get one – by buying or renting or by inviting himself somewhere as a guest.
I would suggest, though, that we must look at the context of this halacha. The Rambam had just finished stating that the berachah recited on both voluntary and obligatory mitzvos must be recited prior to performing the mitzvah. Perhaps the Rambam categorizes lighting Chanukah candles as an obligatory mitzvah because he is referring to someone who lives in a house. The only one who would be reciting the berachah on lighting Chanukah candles is one who lives in a house, and for that person this mitzvah is obligatory. He doesn’t, though, mean to suggest that a person without a house must endeavor to acquire one for Chanukah.