Yes, you need a permit to visit Machu Picchu, which can be purchased from the Dirección Desconcentrada de Cultura Cusco website. If you’re traveling as part of a tour, your permit will probably be secured for you ahead of time and just needs to be presented (along with your passport) at the entrance gates. Only a certain number of permits are issued each day (and numbers are set to change due to overcrowding) and you must be accompanied by an official tour guide.