Matty Blair and Jason Walker struck early in the second half to end York's four-match winless run with a 2-0 victory at Aldershot.
The home side could have been ahead at half-time had Craig Reid put his chance away rather than striking the woodwork.
They were made to pay when Walker released Blair to slide the ball past goalkeeper Jamie Young.
Walker, tripped in the box by Sonny Bradley, stepped up to convert his own spot kick and seal the three points.
VIEWS FROM THE DRESSING ROOM
Aldershot Town manager Dean Holdsworth told BBC Surrey:
"We lost possesion cheaply and got picked off. We gave away a cheap penalty, those two goals then affected everything.
"At the moment we need that first goal to give us that belief.
"Losing games is a concern, it's going to be a test now for the players... they need to stand up and be counted."
York City manager Gary Mills told BBC Radio York:
"We had numerous chances today to score a few more and along with that we've had a clean sheet as well so excellent.
"I thought the first half was a bit weird, we didn't get going first half. It was a bit dead for me.
"We addressed that at half time and Matty Blair seemed to find his second wind second half and got into it.
"He needed the game, he's not played an abundance of football and I thought we were excellent second half."