Umar bin Khattab delivered a sermon one Friday in which he spoke of the Prophet of Allah ﷺ and of Abu Bakr. It was a long sermon, and toward its end he said, "People, you eat two plants that I can only regard as foul, this onion and garlic. I saw the Messenger of Allah ﷺ that whenever he detected their smell on a man, he would order him to be taken out to al-Baqi. So whoever eats them, let him kill their odor by cooking them."
أن عمر بن الخطاب خطب يوم الجمعة، فذكر نبي الله ﷺ، وذكر أبا بكر- وذكر خطبة طويلة- قال في آخرها: ثم إنكم أيها الناس تأكلون شجرتين لا أراهما إلا خبيثتين، هذا البصل والثوم، لقد رأيت رسول الله ﷺ إذا وجد ريحهما من الرجل أمر به فأخرج إلى البقيع، فمن أكلهما فليمتهما طبخا.
Muslim narrated it in "Mosques" (567), from Muhammad bin Muthanna, who said, Yahya bin Saeed narrated to us, who said, Hisham narrated to us, who said, Qatada narrated to us, from Salim bin Abu Jaad, from Madan bin Abu Talha, and he mentioned it.