If it is the one in the Dungeon Corridor you first have to be able to get the invisibility cloak in the Gryffindor boy's dormitory. To get to this you need to complete Ginny Weasley's quest when gathering the army.
When you first come to the painting it taunts you to ask a Slytherin for the password. Once you have the cloak use it to follow two Slytherin first year students who convince the portrait to let them through. Eavesdrop on them to get the password, stash the cloak, then go back to the portrait- it will (reluctantly) give access.