סימן יא סעיף טז
בֵּית שַׁעַר, וְהוּא בַּיִת קָטָן שֶׁאֵצֶל שַׁעַר הֶחָצֵר שֶׁהַשּׁוֹמֵר יוֹשֵׁב שָׁם, וּמִרְפֶּסֶת (גָּאנִיג) שֶׁהִיא דֶרֶךְ לַעֲלוֹת בָּהּ לַעֲלִיָּה, וְהַגִּנָּה וְהַדִּיר, פְּטוּרִין מִמְּזוּזָה, כֵּיוָן שֶׁאֵין עֲשׂוּיִין לְדִירָה וְאִם יֵשׁ בַּיִת הַחַיָּב בִּמְזוּזָה פָּתוּחַ לְאֶחָד מֵאֵלּוּ אוֹ לְאַכְסַדְרָה, חַיָּבִים אַף בַּפֶּתַח שֶׁנִּכְנָסִים לָהֶם מֵרְשׁוּת הָרַבִּים, וְלָכֵן שַׁעֲרֵי חֲצֵרוֹת וְשַׁעֲרֵי מְבוֹאוֹת וְשַׁעֲרֵי מְדִינוֹת וַעֲיָרוֹת כֻּלָּם חַיָּבִים בִּמְזוּזָה כֵּיוָן שֶׁבָּתִּים הַחַיָּבִים בִּמְזוּזָה פְּתוּחִים לְתוֹכָן. אֲפִלּוּ עֲשָׂרָה בָּתִּים זֶה פָּתוּחַ לָזֶה וְזֶה פָּתוּחַ לָזֶה (אֲפִלּוּ תִּשְׁעָה הַחִיצוֹנִים הֵם בְּגַוְנָא דִּפְטוּרִים) אִם הַפְּנִימִי חַיָּב בִּמְזוּזָה כֻּלָּם חַיָּבִים. וְלָכֵן שַׁעַר הַפָּתוּחַ מִן הַגִּנָּה לֶחָצֵר, חַיָּב בִּמְזוּזָה (רמב"ם). וְיֵשׁ אוֹמְרִים דְּבֵית שַׁעַר וּמִרְפֶּסֶת, חַיָּבִים אֲפִלּוּ אֵין בַּיִת פָּתוּחַ לָהֶם. וְיֵשׁ לְקָבְעָהּ בְּלֹא בְרָכָה.
A gate house which is a small hut near the gate of a courtyard, in which the watchman stays, or a hallway which serves as a passageway to go up to an attic, or a garden or a corral, are exempt from mezuzah, because [these enclosures] are not made for dwelling. However, if a house which requires a mezuzah is open to any of these enclosures or to a porch, these enclosures then require a mezuzah; even for those doors that people enter from a public thoroughfare. And therefore gates of courtyards and gate of alleyways and gates of provinces and cities all require mezuzos, since houses that require mezuzos open into them. Even if there are ten houses and one is open to the other, and that one in turn is open to another (even if the outer nine houses are all exempt from mezuzah), if the inner house requires a mezuzah, they all require a mezuzah, and therefore a gate which opens from a garden to a courtyard is required to have a mezuzah. Others maintain, however, that a gate house or a hallway must have a mezuzah even if no house opens into them, and therefore one should affix a mezuzah but without reciting the berachah.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)