Considering his drug addiction, prison stint and health issues — diabetes, a couple heart attacks and a liver transplant necessitated from hepatitis C — David Crosby should have been a long time gone.

He’s as surprised as anyone that he’s still alive.

“Nobody has any clue why,” says Crosby, who’ll turn 78 on Aug. 14. “A whole lot of my friends are dead. I think my new motto is gonna be ‘Only the good die young.’ ”

DAVID CROSBY, TED NUGENT FEUD OVER TRUMP VIEWS

Still carrying on, the music legend — who’s in the Rock & Roll Hall of Fame as a founding member of both the Byrds and Crosby, Stills & Nash — is as feisty as ever in the new documentary “Remember My Name,” out Friday, in which he recounts his “checkered history” in vivid detail.

“I’ve done some great things, some terrible things. Of course I remember that s - - t,” Crosby tells The Post. “All I had to do is be willing to tell the truth . . . But considering how old I am, I should be fading off into the distance politely and sort of getting ready to sit down and shut up.”

One major reason why Crosby decided to spill all in the documentary — which takes its name from “If I Could Only Remember My Name,” his 1971 debut solo album — was its producer, Cameron Crowe. The filmmaker’s life as a teenage music journalist in the early ’70s inspired his 2000 movie “Almost Famous.”

“I’ve known him since he was 15,” Crosby says of Crowe. “He was a very, very bright young man, and everybody liked him. I thought he was terrific, and we became friends. He’s been my friend ever since. And he knows, he really knows [about me].”

Among the rich stories that Crosby tells in “Remember My Name” is how Joni Mitchell dumped him by singing out her feelings in a new song she’d written. Though Mitchell went on to date his CSN bandmate Graham Nash, the two exes remain friends.

“I do see her and talk to her,” Crosby says. “I had dinner with her at her place a couple months back. And I do still love her. Our relationship has always been thorny but good.”

In the documentary, he even visits Mitchell’s old house in the Laurel Canyon section of Los Angeles, where Crosby, Stills & Nash formed and wrote their classic “Our House.” “I spent lots of time there,” says Crosby.

The film also details how, after Neil Young joined them — turning them into Crosby, Stills, Nash & Young — they played Woodstock in what was just their second live performance together. Reflecting on the festival’s 50th anniversary next month, Crosby says, “For three days, everybody there was nice to each other. People were nice to each other, they shared, they were kind to each other. And it gave us all hope. All of a sudden, you saw people behaving the way we dreamed we could do it. This was our dream right there.”

But Crosby’s life turned into a nightmare when, while addicted to cocaine and heroin, he was convicted on drug and weapons charges in 1983. He fled, but later turned himself in and served five months in prison in 1986.

CROSBY, STILLS & NASH IS NO MORE, GRAHAM NASH SAYS

Crosby says that prison helped him to finally kick drugs. “It’s the only thing that really worked,” he says. “I had tried going into treatment and it didn’t work. I went into prison, and it worked. It was a s - - tty way to do it.”

Prison was the last time he shaved his trademark mustache, which, the film reveals, was part of how Crosby inspired Dennis Hopper’s character in 1969’s “Easy Rider.” “They don’t allow you to have mustaches in prison,” he says. “They shaved my face and cut my hair.”

While he still rocks the ’stache, Crosby says he is not as much of a “difficult cat” — as he describes himself in “Remember My Name” — as he used to be. “I’m pretty happy almost all the time — unless I think about the president,” he says.

In fact, his anger about President Trump may be the one thing that could persuade Crosby to reconnect and reunite with Stills and Nash, with whom he last played in 2015, at the White House Christmas tree lighting. “I would like to do some get-out-the-vote stuff in this coming year,” he says. “I really want this guy out of the White House. So if they wanted to do that, I’d probably do it with them.”

Currently, Crosby — who will play Lincoln Center Out of Doors on Aug. 11 — has two bands with younger musicians: the electric outfit Sky Trails, which includes his son James Raymond on keyboards, and the acoustic group Lighthouse.

CLICK HERE TO GET THE FOX NEWS APP

But if you’re wondering just why his name comes first in his most famous band — Crosby, Stills & Nash — he puts it simply: “Try saying it any other way. None of the other ways works.”

This article originally appeared in The New York Post.