It may be hard to imagine powerful leaders forging alliances while swatting mosquitoes or making handshake deals when their fingers are sticky from roasted marshmallows. But more than a century ago, politicians figured out that the all-American camping trip was an excellent way to burnish reputations and advance agendas. Few leaders understood this more than presidents Theodore Roosevelt and Warren Harding, who saw the outdoors as the perfect stage for statecraft and statesmanship.

Their widely publicized forest jaunts, in 1903 and 1921, respectively, made them seem manly and accessible to the public. Tolerating chiggers and the cold night air became a way to personalize the presidency. By capitalizing on the broad popular appeal of camping — and its associations with anti-modernism, recreation, restoration, freedom from cares and “wholesome” activities in the woods — these presidents turned an American pastime into a political tool, a strategy that has had enduring legacies. Although there have been no massively publicized presidential camping trips since, presidents have continued to tap into the suggestive power of the outdoors to connect with the public, using wilderness as a lavish backdrop for speeches and photo ops to promote their personal image and policy agenda.

Starting in the second half of the 19th century, pleasure camping was a fantasy version of an idealized pioneer past, with effete, well-read Northeastern doctors and lawyers retreating to the woods to recapitulate the lost “frontier.” Theodore Roosevelt himself was an ardent, and well-off, proponent of the notion that citified men could restore their spirits and remake their bodies by camping in the woods.

But the stories of his bold outdoor exploits also became political capital, appealing to a public that had stepped up its expectations for the president to solve social and economic problems begotten by industrialization, from the greed of powerful corporations to the corruption of political machines. Tales of Roosevelt’s survival prowess and hunting skills burnished his reputation as manly and decisive, equally comfortable staring down a cougar or a robber baron.

In 1903, Roosevelt used one particular camping trip with the beloved conservationist John Muir in Yosemite to advance his personal and political agenda.

Before the trip, Roosevelt professed that he wanted to “drop politics absolutely for four days.” But in fact the trip became an opportunity to pursue his environmental goals. Over pan-fried beefsteak and large quantities of black coffee, the two discussed policy. Muir, eager to do some “forest good,” easily convinced the president that Yosemite Valley must revert to federal control to clean it up.

Spending a glorious night sleeping in the Mariposa Grove did more than convince the president to make these sites revert to federal control as part of Yosemite National Park. He also got a valuable ally in his fight to advance conservationist goals that were far more sweeping and ambitious than those of any previous president.

There were publicity benefits as well. While Roosevelt allowed no pesky journalists on the trip, he posed for photos with Muir at Glacier Point — Roosevelt’s legs anchored to the rock, a Stetson hat shading his eyes. Roosevelt understood the power of photo ops to shape public opinion directly, and he had his eyes on the 1904 election. This 14,000-mile excursion through western states — which also included a Yellowstone camping trip with another famous writer and naturalist, John Burroughs — was, in part, a calculated attempt to win electoral votes in California, a state in which Muir was a celebrity.

In the end, this trip to the woods may or may not have won him votes, but it was a major boon to the conservation movement. Roosevelt subsequently established five national parks, 150 national forests and 18 national monuments.

While conservation policies were not as much of a priority for President Warren Harding in the early 1920s, photo ops were. And he too saw the electoral potential of camping and took part in a 1921 auto-camping trip to the hills of rural Maryland. By then, camping had also changed. Better roads and mass-produced mechanized vehicles and trailers made it easier to bring more luxuries and amenities into the forest.

This kind of camping had little in common with the “strenuous” wilderness excursions championed by Roosevelt. Notably, photos of Harding’s excursion showed the paunchy president relaxing rather than conquering nature.

But these images served the same purpose of connecting the president directly to his supporters — both the general public and the men who made the 1920s consumer economy possible. Harding joined the nation’s leading industrial titans — Thomas Edison, Henry Ford and the tire magnate Harvey Firestone — to go on this anti-modernist retreat to rural America while making full use of their own inventions and innovations. Edison even brought along his mobile electric generators to supply the camp with electricity.

These men slept in World War I surplus tents, but they also had two chefs at their disposal, a player piano and a kitchen car known as the “Waldorf Astoria on wheels,” with a refrigerator to chill the steaks. This was glamping, Roaring Twenties-style.

As president, Harding used motion pictures for newsreels, state of the art advertising techniques and billboard posters to extend the public presidency that Theodore Roosevelt had launched. Harding’s auto-camping trip was a chance to play up his down-to-earth public image and for his companions to sell goods. The president received adoring coverage for the camping trip. So too did Ford and Firestone, who used the publicity to tap into the “auto camping” craze and encourage more Americans to hit the road themselves — with Ford’s and Firestone’s products as their means of “escape,” of course.

Presidential camping as both a tool to advance conservation policies and a public relations tactic has had enduring legacies.

Though Barack Obama did not camp out during his 2016 tour of national parks, the president posed for the cameras in front of nature-filled backdrops. His tour, like Roosevelt’s camping trip, turned out to be a widely publicized build-up to bold conservation decisions — including designating a national monument in Maine by using the 1906 Antiquities Act that Roosevelt had signed into law.

In this way, Obama was tapping into the legacy of the early 20th-century presidential campout. Camping in and of itself was a powerful symbolic act, signifying renewal, relaxation and a return to “frontier values.” Harding, for instance, invoked the memory of America’s pioneers while visiting western national parks as part of his 15,000-mile “tour of understanding,” a final attempt to reconnect with the public shortly before his death in 1923.

Roosevelt’s love for the forest was long-standing and genuine, and he described his campouts as a cure for stress-induced “neurasthenia.” Harding sometimes described the White House as a jail and would take any excuse he could find to get away. But in the end, their campouts were not a form of escape. If anything, the woods were another powerful and resonant way to reassert their influence and power.

In reflecting the needs and changing priorities of their public, cozying up to the hearth with powerful men and posing amiably for photographs, they turned their camping trips into a kind of message-craft, using the campfires to show themselves in the best possible light.