Yamamoto was born in Kagoshima in Satsuma Province (now Kagoshima Prefecture) as the son of samurai who served the Shimazu clan. As a youth, he took part in the Anglo-Satsuma War. He later joined Satsuma's Eighth Rifle Troop; in the Boshin War that ended the Tokugawa shogunate, fighting at the Battle of Toba-Fushimi and other locations; he was also aboard one of the ships that pursued Enomoto Takeaki and the remnants of the Tokugawa fleet to Hokkaidō in 1869.