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?

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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