SN 45.2
PTS: S v 2
CDB ii 1524
Upaddha Sutta: Half (of the Holy Life)
translated from the Pali by
Thanissaro Bhikkhu

I have heard that on one occasion the Blessed One was living among the Sakyans . Now there is a Sakyan town named Sakkara . There Ven. Ananda went to the Blessed One and, on arrival, having bowed down to the Blessed One, sat to one side. As he was sitting there, Ven. Ananda said to the Blessed One, "This is half of the holy life, lord: admirable friendship, admirable companionship, admirable camaraderie." [1]

"Don't say that, Ananda. Don't say that. Admirable friendship, admirable companionship, admirable camaraderie is actually the whole of the holy life. When a monk has admirable people as friends, companions, & comrades, he can be expected to develop & pursue the noble eightfold path.

" And how does a monk who has admirable people as friends, companions, & comrades, develop & pursue the noble eightfold path? There is the case where a monk develops right view dependent on seclusion, dependent on dispassion, dependent on cessation, resulting in relinquishment. He develops right resolve... right speech... right action... right livelihood... right effort... right mindfulness... right concentration dependent on seclusion, dependent on dispassion, dependent on cessation, resulting in relinquishment. This is how a monk who has admirable people as friends, companions, & colleagues, develops & pursues the noble eightfold path.

"And through this line of reasoning one may know how admirable friendship, admirable companionship, admirable camaraderie is actually the whole of the holy life: It is in dependence on me as an admirable friend that beings subject to birth have gained release from birth, that beings subject to aging have gained release from aging, that beings subject to death have gained release from death, that beings subject to sorrow, lamentation, pain, distress, & despair have gained release from sorrow, lamentation, pain, distress, & despair. It is through this line of reasoning that one may know how admirable friendship, admirable companionship, admirable camaraderie is actually the whole of the holy life."

Notes

1 .
As AN 8.54 points out, this means not only associating with good people, but also learning from them and emulating their good qualities.