Since you're asking about buying a rental property, then you should work with a Realtor that specializes in investment properties. There's no firm rule that you must put down 20%, since some programs ask for only 10% down. But in general, lenders require at least 25-35% down.
Landlords can ask for whatever security deposit makes sense, typically 1-2 months plus a reasonable damage deposit, but it's up to each landlord and state law. Google Landlord Tenant law for ME to know exactly what you should expect.
Here in Maine, an owner can ask you for 1 or 2 months security deposit plus 1st month rent. Or some combination of the above such as first, last and one month security.........in other words, three months rent to move in. That is the legal maximum.