מצוה להניחה על פתח ביתו מבחוץ - ומיירי דליכא חצר אלא בית עומד סמוך לרה"ר אבל אם יש חצר לפני הבית מצוה להניח על פתח חצר דאמר לקמן חצר שיש לה ב' פתחים צריכה ב' נרות ואמרי' נמי נר שיש לה שני פיות עולה לשני בני אדם משמע לשני בתים ואם היו מניחים על פתחי בתיהם היה לזה מימין ולזה משמאל אבל אי מניחים על פתח החצר אתי שפיר: It is a commandment to place it at the entrance to one’s house on the outside: And it is speaking about when there is no courtyard, but is rather a house standing adjacent to the public domain. But if there is a courtyard in front of the house, the commandment is to place [it] at the entrance of the courtyard. For later on (Shabbat 23a), it says, "A courtyard that has two entrances requires two lamps." And we also say (Shabbat 23b), "A lamp that has two spouts counts for two people." This implies two houses; but if they placed [it] at the entrance of their houses, it would be to the right for this one and to the left for that one (whereas it should be to the left for both of them). But if they place [it] at the entrance to the courtyard, it comes out fine.
ובשעת הסכנה - נראה לר"י דהיינו מכי אתו חברי לבבל כדאמר בפ' כירה (לקמן שבת דף מה. ושם) מהו לטלטל שרגא דחנוכתא מקמי חברי בשבתא וא"ת דעל השלחן נמי יקחו אותו כדאמר בגיטין (דף יז.) רבה בר בר חנה חלש אתא חברא שקל שרגא מקמייהו וי"ל דאין רגילות כ"כ לחפש בבתים: And in a time of danger: It appears to RI that this is from the time that the chabarei (Zoroastrian fire priests) came to Babylonia, as it said in the chapter [entitled] Kirah (Shabbat 45a), "What is [the ruling with regard] to moving a Channukah lamp from before the chabarei on Shabbat?" But perhaps you will say, "They would also take it from upon the table, like it said in Gittin (17a), 'Rabbah bar bar Chanah became ill. A chabar came and took the light in front of them." But it can be said (answered) that they are not so accustomed to search inside houses.