No private party can ban you from owning a gun. However, if you rent your home, your landlord might be able to prevent you and other tenants from bringing, or keeping, a gun in your own home. Also, know that you can be evicted for possessing a gun if your rental or lease agreement prohibits it.
While the Second Amendment does protect the rights of gun owners, it only protects those rights from governmental intrusion, just like the First Amendment and free speech. This means that unless your landlord is a governmental entity, like a city, or state, agency, or receives state or federal funding for rental assistance on your property, the Second Amendment is unlikely to apply.
Gun Owners Are Not a Protected Class
Gun owners might feel somewhat slighted as a result of the lack of protection from private party landlords that abridge their right to keep a firearm at home. Unfortunately for those slighted gun owners, civil rights laws don't consider gun owners as a protected class. But, one California case is seeking to make gun merchants a protected class under the state's civil rights laws.
If this doesn't make sense to you, just compare it to actual illegal discrimination. Unlike housing discrimination based upon race, national origin, gender, or disability, a gun owner has the option to store their guns elsewhere. A "no wheelchair policy" would prevent a wheelchair user from being able to live in a rental, while a "no gun policy" only prevents a gun owner from storing, or bringing, their guns on the property.
There have been a few pushes by the NRA and state law makers to prohibit landlords from prohibiting firearms. These pushes tend to focus on prohibiting landlords that receive some form of government funding from having "no gun" policies and terms in their leases.
However, when it comes to enforcing a "no gun" policy or lease term, a landlord will not have many options, particularly if the tenant does not show off the firearm, or discharge the firearm on the property. A landlord does not have the right to search a property for firearms, and cannot make you open a safe. A landlord can inspect their property for maintenance, and other business related reasons, but those inspections do not allow landlords to search a tenant's personal belongings.