I had the similar problem in my Frontier. I changed the Ignition Switch. That solved the problem.
The ignition switch has normally two parts. The front part where the key goes in, and the back part where the electronic/mechanical part goes.
see the pictures:
Nissan Xterra Frontier Pathfinder...