Ehrhardt was born on 29 April 1805 in Zella St. Blasius, Saxe-Gotha-Altenburg. He was the son of a poor gunsmith who worked in Jäger'schen wire drawing plants. When a master gunsmith visited Ehrhardt's parents, he saw Ehrhardt's technical skills and allowed him to become an apprentice gunsmith. Ehrhardt's first job as a journeyman was at the mint in Gotha.
Ehrhardt moved to Belgium in 1831. He worked for an optician in Brussels for half a year before moving with the John Cockerill company to Seraing, where he worked in steam engineering. While working with dewateringmachines, he invented a rear cargo compartment. To acquire theoretical knowledge for future work, Ehrhardt went to the Polytechnic Institute in Düsseldorf for three months, starting in November 1833. That same year, preparations began for the construction of Le Belge, the first steam locomotive manufactured in Belgium. The locomotive was completed in 1835 by Robert Stephenson and Company, for use on a planned railway from Brussels to Mechelen. In 1836, Ehrhardt attended the Arts and Crafts School in Düsseldorf for further theoretical studies and to improve his skills in technical drawing. Afterward, he returned to his home in Zella-Mehlis.
While at a trade fair in Leipzig in October 1838, Ehrhardt met one of the directors of the Saxon engineering company in Chemnitz, who hired him to buildsteam engines and locomotives. From 1839–1840, Ehrhardt helped to develop the Teutonia and Pegasus locomotives. The Teutonia was provided for the Magdeburg–Leipzig railway, but could not be put into operation because it was too heavy for the railway's infrastructure. It was instead sold to the Magdeburg-Steamship Company. The Pegasus was acquired, after one year of probation, by the Leipzig–Dresden Railway Company, which used it until 1861. From 1843 to 1868, Ehrhardt worked in Dresden as the chief machinist for the Saxon-Silesian railway company, renamed Saxon State Railways after its nationalization in 1851. He invented the two-sided brake with oscillatory waves in 1847, and the portable Ehrhardtsche scale to control axle loads in 1879. He also helped to improve the preheating of condensation devices.