# Log into different domains on one server



## drhowarddrfine (Jun 12, 2019)

I just set up a second web site on my personal server--not in a jail--and realized I wanted to be able to log in as doc@domain2.com and not just doc@domain1.com. Right now I log in to domain1 with ssh but, when I login to domain2.com, my hostname in my prompt shows as domain1.com. So I don't know, or I've forgotten, how to do that if it's possible at all.

What I want to be able to do, among other things, is have the ability to send mail as either doc@domain1.com or doc@domain2.com depending in which domain I logged into. It would be nice to `su` into either domain, too, and accomplish the same thing but that might involve `MASQUERADE` in sendmail.mc. I'm just now looking into that side of things so I'm still trying to get back up to speed and that may be a separate topic altogether.

Can someone get me started or point me in the right direction?


----------



## obsigna (Jun 12, 2019)

I fear this won’t be very helpful for your goal. However, the hostname which is shown in the shell's prompt would be the one which has been configured with the hostname directive in /etc/rc.conf. I cannot tell whether this can be changed session wise.


----------



## SirDice (Jun 13, 2019)

Unless you use something like AD or Kerberos for authentication/authorization you don't login on a domain, you login on a host. The domain you refer to is just a DNS naming construct, it has no relation to your user account on the host.

Mail masquerade works like port redirection with NAT. You can only redirect a port once because there's no way to tell which of the two redirects should be used. Same with mail, you can only translate your local user name to a full email address once. It has no way of knowing, in advance, which translation would need to be used. 

That said, you can accomplish this but it requires you to explicitly state which email address should be used every time you send an email. If you don't supply a source address it's going to use the default.


----------



## drhowarddrfine (Jun 13, 2019)

Yeah, I pretty much knew about how to handle sendmail. I just thought there might be something I wasn't thinking about as far as logging in--that there might be a way. 
I had a guy who worked for me that I wish I could still ask questions of but he was hurt in a car accident that really messed him up. We both suffered from that.


----------

