Abu Musa Ashari reported,

A solar eclipse occurred during the time of the Messenger of Allah ﷺ, so he rose in alarm, fearing that the Hour had come, until he reached the mosque. He stood and prayed, prolonging his standing, bowing, and prostration more than I had ever seen him do in any prayer. Then he said, "These signs that Allah sends do not occur for the death or life of anyone, but Allah عز وجل sends them to instill fear in His servants. So when you see any of them, hasten to His remembrance, supplication, and seeking His forgiveness."

Azami 2976

Sahih

عن أبي موسى الأشعري قال

خسفت الشمس في زمان رسول الله ﷺ فقام فزعا يخشى أن تكون الساعة، حتى أتى المسجد، فقام يصلي بأطول قيام وركوع وسجود، ما رأيته يفعله في صلاة قط، ثم قال: إن هذه الآيات التي يرسلها الله، لا تكون لموت أحد ولا لحياته، ولكن الله عز وجل يرسلها يخوف بها عباده، فإذا رأيتم منها شيئا فافزعوا إلى ذكره ودعائه واستغفاره.

الأعظمي 2976صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Eclipse prayer
Section
Command to pray during an eclipse
Numbering
Jami al-Kamil 2976 (2nd edition)
Azami 2976