Narrated Jabir bin `Abdullah and Salama bin Al-Akwa`:While we were in an army, Allah's Messenger (ﷺ) came to us and said, "You have been allowed to do the Mut'a (marriage), so do it
Hadith No. 5117
Sahih al Bukhari