This excerpt is taken from the book "Fazail al-Jihad" by Sheikh Abi Abdul Saboor Abdul Ghafoor Damni.
عن سالم أبى النضر مولى عمر بن عبيد الله وكان كاتبا له قال كتب إليه عبد الله بن أبى أوفى رضى الله عنه فقرأته أن رسول الله صلى الله عليه وسلم فى بعض أيامه التى لقي فيها انتظر حتى مالت الشمس ثم قام فى الناس خطيبا قال أيها الناس لا تتمنوا لقاء العدو وسلوا الله العافية فإذا لقيتموهم فاصبروا واعلموا أن الجنة تحت ظلال السيوف ثم قال: اللهم منزل الكتاب ومجري السحاب وهازم الأحزاب اهزمهم وانصرنا عليهم.
It is narrated from Salim Abu al-Nadr, who was a servant and scribe of Umar ibn Ubayd Allah, that he wrote to me from the Companion of the Prophet, Abdullah ibn Abi Awfa, may Allah be pleased with him. I read the letter, in which it was mentioned that during a jihad in which a battle took place, the Prophet Muhammad, peace be upon him, did not start fighting until the sun had set. Then the Prophet, peace be upon him, stood to deliver a sermon and said: "O people! Do not harbor the desire or wish in your hearts to fight the enemy, and pray to Allah for peace and safety. However, when you do encounter the enemy, then show patience and steadfastness. And know that Paradise is under the shade of swords." Then the Prophet, peace be upon him, prayed: "O Allah! The One who revealed the Book, and who moves the clouds, and who defeats armies, defeat them and help us against them."
Reference: (Sahih Muslim) (Narrated by Bukhari, Book of Jihad and Expedition, Chapter: The Prophet, peace be upon him, did not fight at the beginning of the day and delayed fighting until the sun set, wording as it is, Number: 2966 / 2965 Muslim, Book of Leadership, Chapter: Dislike of wishing to meet the enemy and the command of patience upon meeting, Number: 1742)
Explanation
From this hadith, it is understood that war should be avoided as much as possible; if a good form of peace can be achieved, it should be adopted because Islam is strongly against sedition and corruption. However, if no form of peace can be made and the enemy is ready to confront, then one should firmly face the enemy. At such a time, the prayer mentioned in this hadith should be recited frequently.
"Paradise is under the shade of swords," means that financial and physical sacrifice is required for Paradise. The bargain for Paradise is not cheap, as stated in Surah At-Tawbah:
إِنَّ اللَّهَ اشْتَرَىٰ مِنَ الْمُؤْمِنِينَ أَنفُسَهُمْ وَأَمْوَالَهُم بِأَنَّ لَهُمُ الْجَنَّةَ
"Allah has purchased from the believers their lives and their wealth in exchange for Paradise."
Reference: (9-At-Tawbah:111)