Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server setup with several domains and subdomains.

I'd like to limit ssh and sftp access so a user can only connect to but I'm not sure where this is configured.

Connecting via ay other domain/subdomain on the server should be refused.



share|improve this question
Why are you trying to do this? It makes no difference in the end whatsoever. – fahadsadah Jun 6 '10 at 13:03
up vote 3 down vote accepted

Since SSH doesn't know something like the Host header in HTTP/1.1, you cannot deny a specific user to login to your server. The SSH daemon can't know which domain originally resolved to the IP address it is listening on.

You could only get another IP address, set it as A resource record for and allow the user only to login on that specific IP address.

share|improve this answer

I believe you can use the hosts.allow and hosts.deny files to limit access to sshd.

Add the following line to /etc/hosts.deny:

sshd: ALL

And add the following to /etc/hosts.allow:


Additionally, you can use denyhosts to further protect sshd from unwanted access.

share|improve this answer
Don't do this! I have lost SSH access after following this comment... – baptx Jul 25 '14 at 17:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.