SUMMARY: Automatic login at boot time on Solaris 2.x

From: James L Bovitz (
Date: Tue Dec 09 1997 - 07:16:23 CST

Thanks to all who responded to my original question regarding how to get a
SOlaris 2.x machine to automatically log in as a user at boot time.

Original Post:

> We had written a small utility that one could install in the /etc/ttytab
> file on SunOS 4.1.4
> that would allow the system to automatically log in as a specified user
> bring up
> OpenWindows with our application running - all without user intervention.
> ---- original ttytab SunOS 4.x ----
> # name getty type status comments
> #
> console "/usr/etc/getty cons8" sun on local secure
> ---- modified ttytab SunOS 4.x ----
> # name getty type status comments
> #
> console "/usr/appdir/bin/ru <user name>" sun on
> secure
> Does anyone know of a way to achieve the same functionality under Solaris
> 2.6?

Dieter Gobbers (gobbers@faw, responded with:

     add something like

     ru:23:respawn:/usr/appdir/bin/ru <user name>

     in /etc/inittab.
     But be careful and read the manpages before ;-)

Glenn Satchell ( responded with:

     What about putting it in a script in /etc/rc3.d/S99ru that does the

Joe Yao ( responded with:

     Write a script that sets appropriate envoronment variables, opens
     and stdout and stderr, and does whatever 'init' used to do for
     Call this program from inside 'inittab' with an appropriate label and
     an appropriate level.

I ended up creating the following entry in /etc/inittab which calls the
script that follows.

     mp:34:wait:/<path to bin directory>/auto_login >/dev/console
2<>/dev/console </dev/console

Auto_login script:

# @(#)auto_login.csh 1.1 97/12/08 (c) Copyright 1997 RSA

set HOME = <path to users home directory>
set USER = <user name>

# Verify that our user exists.

set exists = `ypmatch $USER passwd >& /dev/null`
if ( "$exists" == "" ) then
     set exists = `grep "^^$USER" /etc/passwd`
     if ( "$exists" == "" ) then
          echo "Could not locate $user in either the NIS passwd map or"
          echo "/etc/passwd. Without this user, the SW loaded"
          echo "in ${HOME} cannot run."
          echo "Please check that the installation completed successfully."
          exit 1

# see if dtlogin session is already running - if so stop it
set dtrunning = `ps -eaf | grep dtlogin | grep -v grep | head -1 | awk '{
print $2 }'`
if ( "$dtrunning" != "" ) then
     /etc/init.d/dtlogin stop

# The following line changes the ownership and mode of files (like /dev/fbs
# and /dev/kbd) that OpenWindows uses. By default, these files have a
# permission of 0600 and are owned by root. Normally, login(1) sets these
# permissions and modes however... as usual we are not normal. This is
# necessary for OpenWindows to run for a non-root user.
/usr/bin/chown $USER /dev/console /dev/kbd /dev/fbs/* /dev/sound/*
/dev/mouse >& /dev/null

# Now launch OpenWindows as the non-root user
# Note that this will cause the error message "can't access tty - no job
control for
# this shell" when the program runs. This is normal and will not cause any
# with running the system.

su - $USER

# Done.

Best Regards,
_/_/ James L. Bovitz II _/_/
_/_/ Senior Field Engineering Coordinator _/_/
_/_/ RSA, Inc. - 25 N. Washington Street Rochester, New York 14614 _/_/
_/_/ Phone:(716)327-7134 Fax:(716)262-4808 _/_/
_/_/ Web Site: _/_/

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:11 CDT