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?


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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