EXHIBIT 23.1

Consent of Independent Registered Public Accounting Firm

We consent to the incorporation by reference in Registration Statement No. 333-05799 on Form S-8 of our report dated June 26, 2026, appearing in this Annual Report on Form 11-K of the A.O. Smith Retirement Security Plan for the year ended December 31, 2025.

/s/ Reilly, Penner & Benton LLP

Reilly, Penner & Benton LLP
Milwaukee, Wisconsin
June 26, 2026