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."
Aldershot Town 21 Young 02 Herd 03 Tonkin 04 Morris 05 Brown Booked (Payne - 57' ) 06 Lancashire 23 Bradley 17 Mekki (Rodman - 57' ) 26 Donnelly (Rankine - 84' ) 10 Hylton 20 Reid Booked Substitutes 29 Morris 07 Rodman 15 Branston 24 Anderson 08 Payne 09 Rankine 25 Appiah York City 24 Ingham 02 Oyebanjo 04 Smith 06 Parslow 16 Fyfield 23 Doig 17 Blair 26 McLaughlin (Reed - 60' ) 09 Walker (Johnson - 90' ) 10 Chambers 11 Coulson (Challinor - 60' ) Substitutes 01 Musselwhite 22 Carlisle 27 Taylor 12 Bullock 20 Challinor 07 Reed 14 Johnson
Ref: Carl Berry