The Prophet ﷺ said, "Whoever plants crops on someone else's land without their permission has no right to any of the produce, but he is entitled to recover his expenses."
حدثنا قتيبة حدثنا شريك بن عبد الله النخعي عن أبي إسحق عن عطاء
أن النبي ﷺ قال من زرع في أرض قوم بغير إذنهم فليس له من الزرع شيء وله نفقته
Agreed upon [by Bukhari and Muslim]. Muslim narrated it in the Book of Gifts, chapter on the dislike of favoring some children over others in gifts, no. 1623, from the hadith of Sufyan bin Uyayna, and Bukhari, no. 2586, from the hadith of Zuhri, with the same wording.