Slice the skin off the cucumber, as this is the fruit's most bitter part, according to Washington State University.
Locate the entrance area used by the ants, such as a hole in your wall, and notice the path taken by the ants from the entrance point to other areas of your home, such as a kitchen counter.
Eliminate any visible ants using a vacuum cleaner or damp paper towel. Discard the paper towel into the toilet when finished.
Wipe the inside portion of the cucumber skin over any areas previously covered by the ants.
Place the cucumber skin at the kitchen entrance point. The smell of the cucumber confuses the ants and keeps them from returning to that particular area.