Instead of a rash of big plays, as is often the case when Stanford plays USC, Saturday night’s Pac-12 opener was mostly a defensive struggle. The Cardinal nearly pitched a shutout.

Tenth-ranked Stanford harassed freshman quarterback JT Daniels and shut down the No. 17 Trojans most of the night to earn a 17-3 win at Stanford Stadium.

Stanford allowed only a Chase McGrath field goal of 35 yards in the third quarter. It was the fewest points USC has scored against Stanford since a 13-0 shutout at the Los Angeles Coliseum in 1941.

Head coach David Shaw predicted the Cardinal would rise “too far” in the national rankings this week.

“This is only Game 2,” he said. “We’re going to get too many pats on the back this week, I know that. That’s what happens when you win. But we can be so much better.”

Bryce Love, a week after being held to 29 yards by San Diego State, broke free for 136 yards on 22 carries, including a 6-yard touchdown run and a 59-yard sprint.

The other touchdown came on KJ Costello’s 9-yard touchdown pass to 6-7 tight end Colby Parkinson, who barely got a toe in bounds in the end zone.

Stanford schedule Date Opponent Time/ Result Aug. 31 San Diego St.W, 31-10 Sept.8 USC W, 17-3 Sept. 15 UC Davis 11 a.m. Sept. 22 at Oregon TBD Sept. 29 at N. Dame4:30 p.m. Oct. 6 Utah TBD Oct. 18-y at ASU 6 p.m. Oct. 27 WSU TBD Nov. 3 at Wash. TBD Nov. 10 Oregon St. TBD Nov. 17 at Cal TBD Nov. 24 at UCLA TBD y - Thursday

Read More

But the defense was the big story for the Cardinal (2-0).

Daniels, under pressure all night, completed 16 of 33 passes for 215 yards. He was sacked four times and briefly forced to the sideline with a hand injury in the first quarter.

“I don’t know that we confused him,” Shaw said. “We tried to pressure him. … The kid made some plays. I have all the respect in the world for him. Wait until this kid plays four or five more games. He’s going to get better and better and better.”

Stanford lost twice to the Trojans last season, including in the conference championship game. So this game of Pac-12 heavyweights was an early showdown, but the paid crowd of 42,856 fell well short of capacity (50,424).

In the two games in 2017, USC piled up 623 and 501 yards of total offense against Stanford. With Sam Darnold, Ronald Jones Jr. and several others gone, the Trojans (1-1) had just 332 total yards.

The closest the Trojans got to a touchdown was a pass that Daniels threw on 1st-and-10 at the Stanford 15, trying to hit Amon-Ra St. Brown in the end zone with 2½ minutes left. Safety Malik Antoine wrestled the ball from St. Brown for the game-sealing interception.

“I’ve got to give credit to our front seven for putting the pressure on” Daniels, Antoine said. “I expected a deep ball probably coming my way.”

For good measure, he intercepted another Daniels pass with 26 seconds left. The two picks were the first of Antoine’s career.

“From the day we moved Malik from corner to safety last spring, it was weird,” Shaw said. “He was always around the ball, forcing fumbles, picking up a fumble, deflecting a pass, intercepting a pass. He’s got great instincts. He’s got great ball skills.”

Costello, who completed 16 of 27 passes for 183 yards, lauded the Stanford defense.

He said he told linebacker Sean Barton and safeties Frank Buncom and Ben Edwards before the game, “We’re going to go as you go. We’re all going to work off each other.”

It wasn’t a sizzling night for the Stanford offense, which posted just 13 first downs. But Costello said the defense provided the needed momentum.

“When there was a third down that we didn’t pick up,” he said, “I really had trust that I was going to be out there pretty quickly. That’s a great feeling as a quarterback.”

Linebacker Joey Alfieri, who took part two sacks, said, “We got 11 guys doing the job.” Daniels “got loose a few times,” Alfieri said. “He’s more elusive than you think. He’s got a bright future ahead of him, for sure.”

Edwards (nine tackles) said, “We wanted to swarm the ball. We wanted to tackle well. We didn’t think we tackled well last week. We wanted to improve, and we did today.”

Tom FitzGerald is a San Francisco Chronicle staff writer. Email: tfitzgerald@sfchronicle.com Twitter: @tomgfitzgerald