Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 am looking for a way to secure my servers with the following setup: I have a server where I can log in via SSH. The main account there (named "foo") is secured by a keybased login with password. I have another user account (named "bar") that I use to log in via cronjobs running on other servers - this one also has keybased login, but without password.

Now I want to limit access to this machine for the "bar" account. The account should only be accessible via known IPs. However, the "foo" account should not be affected by this, this one should basically be accessible from any IP.

How can I manage this? Or is there a simpler solution to everything?

share|improve this question
up vote 3 down vote accepted

Manage this with ssh's AllowUsers directive. In /etc/ssh/sshd_config:

AllowUsers foo bar@hostname

Put the IP and hostname of bar's machine in /etc/hosts on the ssh server (because DNS might be unreachable and the IP might change), restart ssh, and you're all set.

share|improve this answer
Thanks, will give this a try! – j0nes Dec 27 '10 at 22:18

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.