´It was narrated that 'Abdur-Rahman bin Abu Qurad said:` "I went for Hajj with the Prophet and he went far away to relieve himself."
Related hadith on this topic
Explanation & Benefits
Shaykh Muhammad Farooq Rafi
Benefits:
These hadiths mention the etiquettes of relieving oneself, that when in an open place, one should go so far that he becomes hidden from the sight of people. Or, if there are low-lying places where some cover is available, then relieving oneself in such places is also permissible, even if they are near inhabited areas. Similarly, it is also permissible to relieve oneself in a restroom (toilet), or by using a cloth or similar means as a screen. The requirement in relieving oneself is to cover the private parts (awrah); wherever and however this covering is achieved, relieving oneself is permissible and correct.
Source: Sahih Ibn Khuzaymah: Commentary by Muhammad Farooq Rafee, Page: 51