NY state law requires a landlord to give reasonable notice before entering. The state attorney general has previously held in Zwerin v. Geiss that reasonable notice is at minimum 24 hours and up to 1 week depending on the reason.
The petitioner may be able to evict you, as well as garnish your wages or levy on your bank account. If you received a notice from a marshal or a sheriff you may be able to vacate your default and/or stop the eviction.
Ing to precedent set by the Zwerin v. Geiss ruling in 1963, for inspections and showings, your landlord must give you at least 24 hours' notice before arriving, and for repairs they must give at least 1 week's notice.
New York Multiple Dwelling Law states you may your own lock but must provide the landlord with a copy of the key if you do so. If you don't, the landlord could evict you from your apartment for failing to comply with the law.
It is considered harassment if your landlord: Fails to give you the buyout offer in writing; Gives you the buyout offer in writing, but the offer doesn't include all of the required information; Contacts you about a buyout within 180 days of you notifying them that you do not want to be contacted.