1833877 Members
2373 Online
110063 Solutions
New Discussion

Re: Users restriction?

 
ashwin
Occasional Contributor

Users restriction?

hello all,
What are the diifferent ways to restrict users to log on to the system from a specific 'tty'.
eg. user--> should log from tty /dev/pty3 only.
5 REPLIES 5
Paula J Frazer-Campbell
Honored Contributor

Re: Users restriction?

Hi

This may help for root
If the /etc/securetty file is present, login security is in effect.
Only user root is allowed to log in successfully on the ttys listed in
this file. Restricted ttys are listed by device name, one per line.
Valid tty names are dependent on installation. An example is
console
tty01

To control a user to a specificy tty you can put a short scrip in their .profile to pick up their tty and if no match to tty in .profile throw a exit at them, this has the ability to allow a user a range of login ttys.

See man login

HTH

Paula
If you can spell SysAdmin then you is one - anon
Bill Hassell
Honored Contributor

Re: Users restriction?

While you can certainly modify /etc/profile to restrict access by user name, time of day, number of logins allowed per user, terminal port and so on, network logins are a bit more complicated. Your example of a pty login, while possible to test, will likely be of no use as pty ports are assigned not by the requestor but as needed by the system.

Thus, for any given login, the pty (now more likely, a streams pts device file) assigned will be essentially unpredictable.

However, you can certainly test for the name or IP address of the incoming device using who -mur.


Bill Hassell, sysadmin
Tommy Palo
Trusted Contributor

Re: Users restriction?

If you can get hold of the IP-address instead you could use /var/adm/inetd.sec to control access.
Keep it simple
ashwin
Occasional Contributor

Re: Users restriction?

thanks to all,
But what are other ways to restrict pertoculer user to login from /dev/tty3 other than putting a script in .profile.

thankx once again to all.
Bill Hassell
Honored Contributor

Re: Users restriction?

As mentioned, there is no way to predict what tty device the user will have. However, the concept is simple. Put the test in /etc/profile (.profile is under control of the user). The test for the user ID and terminal as well as the incoming hostname or IP address can be combined in one command:

who -muR

Extract the fields like this:

echo $(/usr/bin/who -muR) | awk '{print $1," " ,$2," ",$NF}' | read MYUID MYTTY MYPORT

Now test $MYUID and $MYTTY or $MYPORT. If they don't meet your criteria, then just exit from /etc/profile (with an appropriate message).


Bill Hassell, sysadmin