This article is from a FAQ concerning SCO operating systems. While some of the information may be applicable to any OS, or any Unix or Linux OS, it may be specific to SCO Xenix, Open Desktop or Openserver.

There is lots of Linux, Mac OS X and general Unix info elsewhere on this site: Search this site is the best way to find anything.

Unix, Xenix and ODT General FAQ

How do I restrict logins?

For some reason, I often get requests to limit users to one login. I guess the people asking such questions have a reason for wanting to restrict logins this way. The only way to do it is to add a script to either /etc/profile or the particular user's .profile that tests to see if this user is logged in somewhere else. Something like this in /etc/profile will work:


Hate these ads?

IAM=`who am i | cut -d" " -f1`
COUNT=`w | cut -d" " -f1 | grep "^$IAM$" | wc -l`
[ $COUNT -gt 1 ] && exit 0

Similar tricks can restrict a user to a particular tty:

IAM=`who am i | cut -d" " -f1`
TTY=`tty`
[ $TTY != "/dev/tty07" ] && [ $IAM = "tony" ] && exit 0

And then there's always restricting login to root: put this in /etc/profile

IAM=`who am i | cut -d" " -f1`
[ -f /etc/nologin ] && [ $IAM != "root" ] && exit 0

When you need to restrict logins, just "touch /etc/nologin"; remove it when the need is over.

IN ALL CASES YOU HAVE TO CONSIDER THE EFFECT OF SINGLE USER LOGIN. Tests like this can prevent you from logging in from the CTRL-D single user mode prompt because "who am i" and similar commands will return nothing. Avoid that by using "who -r" to test the run level.

You can restrict root to a particular device by adding a line like



CONSOLE=/dev/tty01


to /etc/default/login (se "man M login").


Technorati tags:  

Comments /SCOFAQ/FAQ_scotec6restrictlogin.html


Add your comments

LOD Communications, Inc.

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


Views for this page
Today This Week This Month This Year  Overall
53551563 2,516

/SCOFAQ/FAQ_scotec6restrictlogin.html copyright 1997-2003 (various) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

More:
       - FAQ




Unix/Linux Consultants


UBB Computer Services Support for Openserver, Unixware and Linux. Windows integration with Unix/Linux servers. Hardware, Backup and Networking issues. Located near Sacramento CA, we provide onsite support throughout Northern CA and Nationwide via remote access. We are a SCO Authorized Partner and a Microlite BackupEdge Certified Reseller.


http://www.m3ipinc.com Security, firewalls, ids, audits, vulnerability assesments, BS7799, HIPAA, GLB, incident handling


http://www.breakthru.com.au SCO (Openserver and Unixware), Unix, Solaris and Linux Consulting services including: Secure Networking Solutions; Linux based Firewalls; Backup Solutions; Secure Home to Office Network Setup; Phone, Remote and On-Site Support available - Satisfaction Guaranteed!


Twitter
  • May 9 07:16
    It's cold again. Dammit Summer, stop teasing me!
  • May 8 21:36
    Won $28.15 at poker tonight..









Change Congress

Related Posts