Removing sources of food and shelter that snakes seek out is the most certain way to keep them away from a home. Snakes can also be kept out with a perimeter snake fence. Chemical snake repellents are available, but they may contain toxins that can harm pets, other wildlife or even humans if they get into a water supply.
Snakes are commonly afraid of humans and rarely come close to homes unless there is a lot of food nearby or they are lacking shelter elsewhere. Snakes mostly prey on rodents, so ensuring that the home is free of rats, mice and insects is a good deterrent. Snakes also like to eat loose food remains, such as improperly secured kitchen garbage or loose pet food.
Snakes prefer a cool and damp habitat, so ensure that possible entry points to the basement or crawl space are sealed. Vents and drains should be covered with galvanized screens. Snakes also like to hide under loose debris and tall grass, and these things may also attract prey vermin looking for shelter.
If all else fails, a perimeter snake fence can be built of wire-mesh screening. It should sit at least 30 inches above ground and be buried at least six inches deep to prevent snakes from burrowing under.