He rocketed to fame as a blood and guts commander who allied himself with pirates and scoundrels. He rode his legend all the way to the White House.