It is forbidden to be secluded with a person with whom sexual relations are forbidden, whether elderly or young. This action leads to uncovering of nakedness. This law does not apply to a mother with her son, a father with his daughter, and a husband with his menstruant wife. A groom whose wife became niddah before consummation is forbidden to be secluded with her. Instead, she sleeps among the women and he sleeps among the men. But if he consummated the marriage and then she became [menstrually] impure, he is permitted to be secluded with her (see Yoreh Deah chapter 192).
After the episode of Amnon and Tamar, David and his court forbade seclusion with an unmarried woman. Even if she is not forbidden as an "ervah" (person with whom sexual relations are forbidden), it is still considered as seclusion with a forbidden sexual partner. Shammai and Hillel forbade seclusion with idol-worshippers (non-Jews). Therefore, anyone who is in seclusion with a woman with whom seclusion is forbidden, whether Israelite or idol-worshipper, [the court] administers lashes of rebellion (makat mardut - Rabbinically sanctioned lashes) to both, the man and the woman, and the punishment is publicized. Note: [We administer lashes] only if it is known that he secluded with her, but her testimony alone is not sufficient [to convict him] (Rivash chapter 265). Even a single witness is not believed (Maharik root 189). Nevertheless, when the court has reason to believe that there was a transgression, it is necessary to separate them (Rivash ibid.). However, with a married woman, even though it is forbidden to be secluded with her, if one did so, they do not administer lashes so as not to spread rumors that she had relations (with him), which would lead to rumors that her children are mamzerim (the products of a sexually forbidden union).
If his wife is with him, it is permitted to be secluded with any woman with whom seclusion is [usually] forbidden, since his wife guards him. But an Israelite woman may not seclude with an idol-worshipping male even if his wife is with him.
We do not give over a Jewish child to an idol worshiper to teach him a book or a craft.
One woman may not be in seclusion even with many men, unless the wife of one of the men is present. And similarly, one man may not be in seclusion even with many women. Note: And there are those who say that a woman may seclude herself with two "good men" [of fit morals] when in-town. And men are to be considered as good men, generally. But if they are "steeped" [in sexual immorality], it's forbidden to be secluded even with ten of them. And all this [applies] when in-town. However, in the field, or during the night even in-town, three men are required to be there, even if they are "good men". And there are those who permit one man with many women, if his business is not [primarily] involved with women.
If there were many women with many men, we're not concerned about "yichud" [the prohibition of seclusion]. If the men were outside and the women inside, or the men inside and the women outside, and a woman separated to be among the men, or one man to be among the women, they are forbidden due to "yichud".
Even a man whose business and job is [primarily] with women is forbidden from secluding himself with the women. What should he do? He should do his business with them while his wife is present, or he should switch to another job.
We are not worried to be secluded with a woman whose husband is in-town, since the fear of her husband is upon her. But if he was "familiar with her", such as if she grew up with him or is his relative, or her husband adjured her not to be in seclusion with him, then he may not be secluded with her, even though her husband is in-town.
A house whose door is open to the public domain, there is no concern for seclusion there with an "ervah" (person with whom sexual relations are forbidden).
It is permitted to seclude with two women bound for levirate marriage; or two co-wives; or a woman with her mother-in-law; or a woman with the daughter of her husband; or a woman with the daughter of her mother-in-law, because they are antagonistic to (lit. hate) one another and will not cover-up for one another. Similarly [it is permitted to be secluded] with a woman who has with her a young female child who [is old enough to] understand the nature of intercourse but [is young enough that she] will not offer herself for intercourse, the adult woman will not engage in promiscuity in front of the child because she will reveal her secret.
A girl younger than 3 years old, or a boy younger than 9 years old, it is permitted to be secluded with them, for [the Sages] only forbade seclusion only with a woman or man fit for [legally accountable] intercourse.
One who is androgynous may not seclude with women. But if one does seclude, they are not lashed because their status is doubtful. A man is permitted to seclude with one who is androgynous or a tumtum
Our Sages instituted that women should talk to one another in the toilet, so that a man will not enter there and be in seclusion with them. Note: And some say that this applied only in ancient times when the toilets were in the fields, but nowadays that toilets are in the city, there is no concern (Hagahot Maimoni, Hilchot Issurei Biah chapter 22).
A woman should not walk in the market with her son behind her, for fear that someone will grab her son, and when she goes after her son to return him, the kidnappers will abuse her.
We do not appoint a man -- even a reliable and worthy man -- to be a watchman in a courtyard in which there are women, even if he stands outside, for there is no trustee for arayot (i.e. even pious men may become ensnared. C.f. GR"A who quotes Yerushalmi Ketuboth chapter 1).
A man should not appoint a guardian for his house, so that he does not lead his wife to stray into transgression.
It is forbidden for a Torah scholar to dwell in a courtyard in which there is a widow, even if he is not secluded with her, because of aspersion, unless his wife is with him.
A widow is forbidden to raise a dog, because of aspersion.
A woman should not purchase male [Canaanite] slaves, even minors, because of aspersion.
An unmarried man should not teach children, for when the mothers come to school to pick up their children, he will arouse the women. Similarly, a woman should not teach small children because their fathers come on account of the children and they will be secluded with her. The [married] teacher does not need to have his wife stay with him in school; it is sufficient that she stay at home and he teaches in his place.