Former Sex Pistols guitarist Steve Jones, 61, recalls his days in the legendary punk band with lots of “shagging” in the new book “Lonely Boy.”

He says his bandmates never “had girlfriends around . . . too much, maybe because they knew I’d end up shagging them. It had become what was expected of me at this point.”

He even “took one for the team and f–ked old Nancy [Spungen],” bandmate Sid Vicious’ infamous girlfriend. “I don’t think he ever found out, and I don’t think he’d be too bothered if he did,” Jones figures of the late Vicious, who was accused of killing Spungen in 1978. “She was so whiny, I was bewildered by what he could’ve found attractive about her — she just seemed to have so little to recommend her as a person.”

Even when not in bed himself, Jones recalls walking onto a window ledge to spy on band member Glen Matlock having sex in another room.

“He’d never have found out he’d had an audience if I’d been able to resist the temptation to give him sex tips over breakfast the next morning,” writes Jones in the Hachette book, out Jan. 10.