This man has the keys to the city — and he’s selling them for a measly 150 bucks.

If the wrong person buys a set, we could all be in trouble.

Retired New Jersey locksmith Daniel Ferraris, 69, is hawking what he calls a “firemen’s key ring” — and what a terrorist might call a dream come true.

The set consists of five keys that would allow control of virtually any elevator in the city, could knock out power to municipal buildings and skyscrapers, darken city streets, open subway gates and some firehouse doors and provide full access to 1 World Trade Center and other construction sites.

Ferraris sold an undercover Post reporter the key-collection ring after posting his wares on eBay under the user name “thesixlever.”

Total cost: $149.95.

He agreed to hand them off at his home in Union City, just minutes from the Lincoln Tunnel, saying the keys “probably still work, but don’t try to use them.” He asked no questions.

Most of the keys did, in fact, work.

Three of the five are standard issue for members of the FDNY, and the set had a metal dog tag that was embossed with an FDNY lieutenant’s shield number, 6896.

The keys include the all-purpose “1620,” a master firefighter key that with one turn could trap thousands of people in a skyscraper by sending all the elevators to the lobby and out of service, according to two FDNY sources. And it works for buildings across the city.

That key also allows one to open locked subway entrances, gain entry to many firehouses and get into boxes at construction jobs that house additional keys to all areas of the site.

The ring sold to The Post has two keys used by official city electricians that would allow access to street lamps, along with the basement circuit-breaker boxes of just about any large building.

The sale of the newer of the two, a Yale 47 key, prompted concern from the city Department of Transportation.

“That key belongs on the key rings of our city electricians, not on the auction block,” an agency official said.

Former FDNY and NYPD Commissioner Howard Safir also sounded the alarm.

“These keys are issued to firefighters for emergency situations,” he said. “Just anyone having them is very dangerous.”

The sale outraged a former member of the FDNY.

“With all the anti-terrorism activities, with all the protection that the NYPD is trying to provide, it’s astounding that you could get hold of this type of thing,” he said.

He walked The Post through a couple of nightmare scenarios that would be possible with the help of such keys.

“Think about the people at Occupy Wall Street who hate the NYPD, hate the establishment. They would love to have a set. Wouldn’t it be nice to walk in and disable Chase’s elevators?” he said.

Or, he said, “I could open the master box at construction sites, which hold the keys and the building plans. Once you get inside, you can steal, vandalize or conduct terrorist activities.”

He said eBay and other online auction sites should stop such sales.

It’s unclear how many more such keys Ferraris has for sale.

But he continues to offer the FDNY elevator key, the master electrical-panel key and two traffic-signal keys on eBay.

He advertises the Yale 2642 key as a “City Wide MASTER key” and claims, “I also have some items NOT permitted for listing on eBay.”

He wrongly stated in the ad that “All items are OBSOLETE and have Not been in use in years.”

The former FDNY member said hawkers typically use the term “obsolete” to skirt eBay rules.

“It’s a security loophole that should have been closed long, long ago,” he said.

Officials at eBay did not return a call seeking comment.

Ferraris told The Post he has long collected FDNY keys from various sources — but he wouldn’t reveal how he obtained the five keys sold to a reporter.

“I get them from different places. I was a locksmith for many years, and I go to shows and get some from collectors,” he said.

He claimed the unauthorized items he mentioned in his ad were antique padlocks used by the New York City transit system, including a heart-shaped New York Rail Transit lock.

“For whatever reason, eBay doesn’t let you sell those items,” he said.

He did not return messages from The Post informing him that he had sold the keys to a reporter — or that merely having them could be illegal.

The NYPD says buying or selling official keys could be a crime — possession of burglar’s tools, a misdemeanor punishable by up to one year in prison.

“It depends on the situation,” said an official at One Police Plaza.

“Are the keys stolen? If you use them, that could be possession of burglar’s tools, but you have to have intent to commit a crime. Just opening something with a key could be considered trespassing. But the real crime would be if you gain access to an area where you’re not supposed to be. That could be burglary.”

FDNY officials initially seemed to shrug off The Post’s findings.

After looking at photos of the keys The Post bought and being given a description, FDNY spokesman Frank Dwyer said the department had “no way of knowing if those keys work, or what exactly they are meant to be used for.”

He did not comment on the fact that the department’s internal keys are being sold to the highest bidder and possibly exposing the city to a terror threat — and that they may have belonged to a current or former officer, Lieutenant 6896.

But later, another FDNY spokesman told The Post that the department is investigating.

“We don’t have anyone by that badge number,” he said.