LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   autologin without GUI (http://www.linuxquestions.org/questions/linux-software-2/autologin-without-gui-374338/)

PFloyd2002 10-18-2005 01:57 PM

autologin without GUI
 
Ok, here's what I'm doing...

I have Debian 3.10 installed on a kiosk machine. I want it to automatically log in as a user so that if there's a power outage, wo don't have to walk around with a keyboard unlocking each kiosk and logging in.

We are NOT using GDM, KDM, etc. If we were, I wouldn't be asking this. We are using XFree86 and fvwm for the window manager. That's it. The only other software is firefox and whatever is installed as a bare minimum (ssh, etc...). Thanks in advance!

homey 10-18-2005 03:08 PM

Here's some notes from an article at http://www.linuxgazette.com/issue72/chung.html

Create a file named autologinfred.c and type in this short C program:
Code:

int main() {
  execlp( "login", "login", "-f", "fred", 0);
}

Run these commands:
gcc -o autologinfred autologinfred.c
chmod 755 autologinfred
cp autologinfred /usr/local/sbin/

Edit /etc/inittab and change the line beginning with "1:2345" so that it reads as follows:
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologinfred 38400 tty1

On some GNU/Linux distributions (like RedHat) /sbin/agetty must be used instead.
1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologinfred 38400 tty1

Make sure the default run level in /etc/inittab is init 1 or init 3
id:3:initdefault:

win32sux 11-04-2005 04:34 AM

any idea why it doesn't seem to work right on slackware??

instead of automatically logging-in a user, it just asks for the password... like, at boot it will say "Password: " (without prompting for a username) and if you give it the password for the user you wanted to auto login it will then drop you to the shell like normal... the only way to log-in as another user is to switch to another console...

this is what my /etc/inittab looks like:
Code:

# These are the standard console login getties in multiuser mode:
#c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c1:1235:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:1235:respawn:/sbin/agetty 38400 tty3 linux
c4:1235:respawn:/sbin/agetty 38400 tty4 linux
c5:1235:respawn:/sbin/agetty 38400 tty5 linux
c6:12345:respawn:/sbin/agetty 38400 tty6 linux

my autologin.c file looks like:
Code:

int main() {
    execlp( "login", "login", "-f", "win32sux", 0);
 }

and i compiled it using:
Code:

gcc autologin.c -o autologin
the permissions for my binary look like:
Code:

-rwxr-xr-x  1 root bin 11066 2005-11-04 03:57 /usr/sbin/autologin
any ideas would be greatly appreciated... :study:

keefaz 11-04-2005 05:24 AM

I installed qlogin in a slackware box to autologin, it works well
(it requires a perl module : User::Utmp)

http://freshmeat.net/redir/qlogin/16...l_tgz/software

win32sux 11-04-2005 07:04 AM

seems the reason it wouldn't work is because i needed to set the NO_PASSWORD_CONSOLE option in /etc/login.defs...

everything is working fine now... i set 3 ttys, tty3 being the one that is autologin...

this is what my working setup looks like now:

/etc/login.defs:
Code:

NO_PASSWORD_CONSOLE tty3
/etc/inittab:
Code:

c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:1235:respawn:/sbin/agetty 38400 tty2 linux
c3:235:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 tty3 linux

~/.bash_profile:
Code:

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty3 ]; then
startx
fi

/etc/securetty (i commented all ttys except tty1):
Code:

tty1
in the inittab i removed the "1" from the c3 line as i don't want the auto login tty3 to be up when i go to runlevel 1 (single user mode)...


Mig21 02-06-2007 01:03 AM

thanks guys, someone asked me how to do this and this thread helped. i wrote down all the steps i followed: http://littlesvr.ca/linux-stuff/arti...ginconsole.php

cheers

NAEET 03-03-2008 02:02 AM

autologin
 
Thank you guys, this thread was very helpful.

What I enjoyed most is the "win32sux" password in the C code ... can't agree more!

frenchn00b 03-26-2008 03:19 PM

Quote:

Here's some notes from an article at http://www.linuxgazette.com/issue72/chung.html

http://linuxgazette.net/issue72/chung.html
Create a file named autologinfred.c and type in this short C program:
Code:

int main() {
execlp( "login", "login", "-f", "fred", 0);
}

Run these commands:
gcc -o autologi
Does it work with Ubuntu ?

-kc- 12-09-2008 10:53 PM

Is there any problem I didn't notice using a shell script instead of C? Seems to work for me:

/etc/inittab:
Code:

c1:1235:respawn:/sbin/agetty -l /path/to/autologin.sh -n 38400 tty1 linux
autologin.sh:
Code:

#!/bin/sh
exec /bin/login -f username

I'd use the above for good measure, but is it any better then just
/etc/inittab:
Code:

c1:1235:respawn:/bin/su - username
?
EDIT3: This is probably useless, since su starts a shell but doesn't open a tty port. Maybe a -c option can be added to start x or something.

EDIT: What's the difference between:
Code:

exec /bin/login -f username
and
Code:

exec /bin/login -- username  #this is what agetty does by default
?

I didn't notice any difference: if one asks for password so does the other and vice-versa (according to /etc/login.defs NO_PASSWORD_CONSOLE item and presence of password).
Is the -f option related to pam? I don't have pam installed.

EDIT2: If someone finds it inconvenient that you can't logout without being immediately relogged in, you can use the action "once" instead of "respawn" in the inittab entry.
If you don't want the tty to become useless after logout you can use a "wait" entry for the autologin, followed by the default "respawn" entry, both at the end of inittab:
Code:

a1:1235:wait:/sbin/agetty -l /path/to/autologin.sh -n 38400 tty1 linux
c1:1235:respawn:/sbin/agetty 38400 tty1 linux


ssanthshtech 05-21-2013 11:53 AM

need help
 
followed same as above but iam using xinit. want to display window launcher on boot time using xinit with user account and having only one tty (tty1). disabled remaining ttys

if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then

su -c "xinit ./myapp" <username>

fi

now my app wants to display at boot time without asking password in user account

FreakboY 07-06-2014 05:32 PM

does anyone knows why NO_PASSWORD_CONSOLE doesn't work on slackware 14.1?

John VV 07-06-2014 07:47 PM

you DO KNOW that this is a 9 year old post about Debian3
and NOT a slackware post


All times are GMT -5. The time now is 09:04 AM.