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 would like to allow a user to login through SSH but with different permission coming from different ipaddress.

For example, a user "tester" login to SSH through and another user login with the same login id "tester" but from different ip

How do I restrict to only allow for viewing the content in the home directory while giving full access?

share|improve this question
up vote 3 down vote accepted

Approach 1 ) Based on the ip you change the shell. If it's just for read only a jail would be fine.

Approach 2 ) Use PAM to do it. The link above can give you a clue of how the whole system is working

share|improve this answer
Thanks for the help. I liked both of your solutions but changing shell depending upon IP how is that done can you elaborate a bit. – Bond Jan 29 '11 at 6:41
A very very quick solution is to have two ssh instances. Let's say port 22 and port 24. Port 22 is for read only, while port 24 is for full access. So, if you can do the port redirection based on ip from iptables. Or you could do something similar with virtual ip addresses – Nikolaidis Fotis Jan 29 '11 at 10:44
@Nikolaidis I have used and configured IPTABLES to redirect port but how do you give read only or full access using IPTABLES this is something new for me let me know. – Bond Jan 29 '11 at 12:20
Ok ... As i said you have two instances of ssh. One in port 22 and one in port 24. Ok so far ? In port 22 you run an sshd with limited priviledges (read only). In port 24 you run a full access sshd. Now, what you have to do it to redirect traffic (iptables) to the proper port depending on ip. For example ( goes to port 22 ) , ( goes to port 24) – Nikolaidis Fotis Jan 29 '11 at 12:25
I am not clear how do you run sshd with limited privilege I never heard any such thing.Is it some thing like chmod 655 or you are doing something like selinux sort of to achieve it. – Bond Jan 29 '11 at 13:15

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.