2nd hadith from the 40 hadith of Imam Nawawi:
Umar ibn Al-Khattab R.A. reported: We were sitting with the Messenger of Allah, peace and blessings be upon him, one day when a man appeared with very white clothes and very black hair. There were no signs of travel on him and we did not recognize him. He sat down in front of the Prophet and rested his knees by his knees and placed his hands on his thighs. The man said, “O Muhammad, tell me about Islam.” The Prophet said:
الْإِسْلَامُ أَنْ تَشْهَدَ أَنْ لَا إِلَهَ إِلَّا اللَّهُ وَأَنَّ مُحَمَّدًا رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَتُقِيمَ الصَّلَاةَ وَتُؤْتِيَ الزَّكَاةَ وَتَصُومَ رَمَضَانَ وَتَحُجَّ الْبَيْتَ إِنْ اسْتَطَعْتَ إِلَيْهِ سَبِيلًا
Islam is to witness that there is no God but Allah and Muhammad is the Messenger of Allah, to establish prayer, to give the alms, the fast the month of Ramadan, and to perform pilgrimage to the House if he is capable of travel.
The man said, “You have spoken truthfully.” We were surprised that he asked him and then said he was truthful. He said, “Tell me about faith.” The Prophet said:
أَنْ تُؤْمِنَ بِاللَّهِ وَمَلَائِكَتِهِ وَكُتُبِهِ وَرُسُلِهِ وَالْيَوْمِ الْآخِرِ وَتُؤْمِنَ بِالْقَدَرِ خَيْرِهِ وَشَرِّهِ
Faith is to believe in Allah, His angels, His books, His messengers, the Last Day, and to believe in providence both its good and its bad.
The man said, “You have spoken truthfully. So tell me about excellence.” The Prophet said:
أَنْ تَعْبُدَ اللَّهَ كَأَنَّكَ تَرَاهُ فَإِنْ لَمْ تَكُنْ تَرَاهُ فَإِنَّهُ يَرَاكَ
Excellence is to worship Allah as if you see Him, for you do not see Him but He certainly sees you.
The man said, “Tell me about the final hour.” The Prophet said:
مَا الْمَسْئُولُ عَنْهَا بِأَعْلَمَ مِنْ السَّائِلِ
The one being asked does not know more than who is asking.
The man said, “Tell me about its signs.” The Prophet said:
أَنْ تَلِدَ الْأَمَةُ رَبَّتَهَا وَأَنْ تَرَى الْحُفَاةَ الْعُرَاةَ الْعَالَةَ رِعَاءَ الشَّاءِ يَتَطَاوَلُونَ فِي الْبُنْيَانِ
The servant girl will give birth to her mistress and you will see barefoot, naked, and destitute shepherds compete in constructing tall buildings.
Then the man left and I remained. The Prophet said to me:
يَا عُمَرُ أَتَدْرِي مَنْ السَّائِلُ
O Umar, do you know who he was?
I said, “Allah and His messenger know best.” The Prophet said:
فَإِنَّهُ جِبْرِيلُ أَتَاكُمْ يُعَلِّمُكُمْ دِينَكُمْ
Verily, he was Gabriel who came to teach you your religion.
Source: Sahih Muslim 4, Grade: Sahih