Ubada bin Samit reported,

The Messenger of Allah ﷺ said, "Will you not pledge allegiance to me upon the same terms on which the women pledged, that you will not associate anything with Allah, that you will not steal, that you will not commit adultery, that you will not kill your children, that you will not bring forth a slander you have fabricated between your hands and feet, and that you will not disobey me in what is right?"We said, "Yes, Messenger of Allah," and we pledged allegiance to him on that.Then the Messenger of Allah ﷺ said, "Whoever commits any of these afterward and is punished for it, that punishment is his expiation. Whoever commits any of them and is not punished, his affair rests with Allah. If He wills, He forgives him, and if He wills, He punishes him."

Nasai 4167

Sahih

أخبرني أحمد بن سعيد قال حدثنا يعقوب قال حدثنا أبي عن صالح بن كيسان عن الحارث بن فضيل أن ابن شهاب حدثه

عن عبادة بن الصامت

أن رسول الله ﷺ قال ألا تبايعوني على ما بايع عليه النساء أن لا تشركوا بالله شيئا ولا تسرقوا ولا تزنوا ولا تقتلوا أولادكم ولا تأتوا ببهتان تفترونه بين أيديكم وأرجلكم ولا تعصوني في معروف قلنا بلى يا رسول الله فبايعناه على ذلك فقال رسول الله ﷺ فمن أصاب بعد ذلك شيئا فنالته عقوبة فهو كفارة ومن لم تنله عقوبة فأمره إلى الله إن شاء غفر له وإن شاء عاقبه

النسائي 4167صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Pledge of allegiance
Chapter
Pledge of allegiance to jihad
Numbering
Darussalam 4167
Nasai 4167