View previous topic :: View next topic |
Author |
Message |
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Sun Oct 24, 2004 2:29 am Post subject: Passwordless console / x user logins [Working] |
|
|
[Edit] The audio bug has been fixed, and works fine on my system.[/Edit]
[Edit2] I've fixed this post so that it works with either the bash or tcsh shell.[/Edit]
[Edit3] I replaced the original post with a much simpler, and better method to do the same. The current post reflects some suggestions from posters below. [/edit3]
If you're the only person who uses your computer, you might want to set it up to start consoles with you automatically logged in at boot up. Additionally, you might also want to start X as your user after boot. This post tells you how to do this (without having to install kdm / gdm).
Note: After using this for a long time on my home computer, I now do the same on my laptop. I figure if someone has physical access to my laptop, he'll just take it away, instead of trying to login in and hack my passwords. Any sensitive information on my laptop I keep encrypted (using encfs). All network services are appropriately firewalled and secured. However a user with *physical* access to the computer never requires a password to login at boot time, or become root via su or sudo.
Instructions to do this are below. Use it only if you know that only trusted will have physical access to the computer.
Password-less Console logins
The follwing will make the virtual consoles at boot time password-less (i.e. will be the login shell of your user, without requiring you to authenticate it):
First create the file /root/bin/autologin, and put the following in it:
Code: | #! /bin/bash
exec login -f <username> |
Make it executible via chmod a+x /root/bin/autologin.
Next modify your /etc/inittab: Replace the line
Code: | c2:12345:respawn:/sbin/agetty 38400 tty2 linux |
with
Code: | np2:12345:respawn:/sbin/agetty -l /root/bin/autologin -n 38400 tty2 linux |
This starts up one console on vt2 where the user (specified in /root/bin/autologin) is automatically logged in. If you'd like more than one console automatically logged in, repeat the above replacement for lines c3 -- c6 as desired. (Don't forget to change 'np2' and 'tty2' to 'np3' and 'tty3' etc.).
Note Once you logout of the console, it will restart (passwordless ofcourse)! If you want a 'dead console' once you logout, then replace the respawn with once above. If you want anything fancier, you need to write a script.
Passwordless X logins (without kdm / gdm)
Display managers like gdm and kdm have a feature that enables you to log in a user automatically. However if you think gdm or kdm take up too much memory (especially if you want to use a twm / openbox / fluxbox / fvwm / lightweight session) you can avoid running a display manager as follows:
Edit /etc/conf.d/local.start and add the lines
Code: | # Start X as user if tty7 is free
if ! fuser /dev/tty7 >& /dev/null; then
su - <username> -l -c 'exec startx -- vt7 >& ~/.xsession-errors' &
fi |
Note: If you use tcsh, you should remove the -l flag.
If local is not part of your default runlevel, then add it:
Code: | rc-update add local default |
Running 'su' without typing your password
Once logged in, if you want to become root without typing the password every time, you can do the following:
Code: | echo <username> > /etc/security/suauth.nopass |
Then edit /etc/pam.d/su and uncomment the line
Code: | auth sufficient pam_listfile.so item=ruser sense=allow onerr=fail file=/etc/security/suauth.nopass |
Last edited by gi1242 on Wed May 23, 2007 8:32 am; edited 6 times in total |
|
Back to top |
|
|
Hauser l33t
Joined: 27 Dec 2003 Posts: 650 Location: 4-dimensional hyperplane
|
Posted: Sun Oct 24, 2004 4:50 am Post subject: |
|
|
Code: | c2:12345:respawn:/usr/bin/openvt -s -e -- /bin/su - gautam |
While this is insteresting, it seems the console will always belong to gautam, namely you can't exit and login as a different user at that console.
Code: | c3:45:once:/usr/bin/openvt -e -- /bin/su - gautam -c /usr/X11R6/bin/startx |
This doesn't work here, as I always get:
Code: | /usr/X11R6/bin/startx: line 111: xauth: command not found
/usr/X11R6/bin/startx: line 112: xauth: command not found
/usr/X11R6/bin/startx: line 111: xauth: command not found
/usr/X11R6/bin/startx: line 112: xauth: command not found
/usr/X11R6/bin/startx: line 150: xinit: command not found
/usr/X11R6/bin/startx: line 1: xauth: command not found |
_________________ AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl
Do I like to compile everything?
Positive definite! |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Sun Oct 24, 2004 5:31 pm Post subject: |
|
|
Hauser wrote: | While this is insteresting, it seems the console will always belong to gautam, namely you can't exit and login as a different user at that console. |
If you want to log in as a different user, try su - <username>. The primary purpose for this post was for people (like me) who essentially have only one user using their machine. So if you have multiple users who use your machine, you probably won't want to do this anyway ...
If you *really* want to have the 'regular' login screen apear after you're done, replace the command with a script which first runs openvt -e ..., and then runs agetty after it. You can use fgconsole to get the number of the console.
Hauser wrote: |
Code: | c3:45:once:/usr/bin/openvt -e -- /bin/su - gautam -c /usr/X11R6/bin/startx |
This doesn't work here, as I always get:
Code: | /usr/X11R6/bin/startx: line 111: xauth: command not found
/usr/X11R6/bin/startx: line 112: xauth: command not found
/usr/X11R6/bin/startx: line 111: xauth: command not found
/usr/X11R6/bin/startx: line 112: xauth: command not found
/usr/X11R6/bin/startx: line 150: xinit: command not found
/usr/X11R6/bin/startx: line 1: xauth: command not found |
|
That's strange. It's been working fine for me for a *while*. It might be because the path's are not set right? Does it work if you replace the 'startx' with a shell script which starts X?
[Edit]I figured out why it doesn't work for you. My default shell is tcsh. It reads the environment files by default. Bash doesn't do it unless you pass a -l. I've edited the post above to reflect this.
GI |
|
Back to top |
|
|
Hauser l33t
Joined: 27 Dec 2003 Posts: 650 Location: 4-dimensional hyperplane
|
Posted: Wed Oct 27, 2004 11:35 am Post subject: |
|
|
Code: | c2:12345:respawn:/usr/bin/openvt -s -e -- /bin/su - gautam |
It seems there's some problem here, after startx, I can't play cd, dvd anymore. If I change back to agetty and relogin, everything works fine again. _________________ AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl
Do I like to compile everything?
Positive definite! |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Thu Oct 28, 2004 6:41 pm Post subject: |
|
|
Hauser wrote: | It seems there's some problem here, after startx, I can't play cd, dvd anymore. If I chage back to agetty and relogin, everything works fine again |
I have the same problem. It is because of the permisions of the mixer / sound files in the /dev directory.
When you login the conventional way, devfsd has an event where it gives you all the permissions. If you don't login (i.e. use openvt), then devfsd does not automatically give you the permissions. I've been trying to figure out how to configure devfsd to give permissions on a particular event etc, but the man page confuses me! Hopefully I'll have better luck later.
If I figure it out, I'll post it. The not so nice temp workaround is to manually change the apropriate permissions
If someone knows somethign, I'd be glad to hear it.
GI |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Tue Nov 09, 2004 4:04 pm Post subject: |
|
|
Ok. I finally figured out the cause of both reported bugs. I've edited the original post to fix them. Works fine on my system ... |
|
Back to top |
|
|
twiggy n00b
Joined: 25 Nov 2003 Posts: 65 Location: Sweden
|
Posted: Thu Nov 11, 2004 1:14 pm Post subject: |
|
|
Looks nice.. gonna check it out later tonight _________________ Bite my shiny metal ass! |
|
Back to top |
|
|
ktm Tux's lil' helper
Joined: 13 Aug 2004 Posts: 144 Location: Denmark
|
Posted: Thu Jan 26, 2006 4:32 pm Post subject: |
|
|
Another simple way to do this is just to add these lines...
Code: | /bin/su - root -l -c /usr/X11R6/bin/startx
/sbin/poweroff |
... to your /etc/conf.d/local.start and then set local to start on boot:
Code: | rc-update add local default |
Now you can forget everything about /etc/inittab and remove all the terminals to get some more of that precious memory |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Thu Jan 26, 2006 6:54 pm Post subject: |
|
|
That's a neato trick ktm. I would also add an
Code: | openvt -fsec 2 -- /bin/su - gautam |
or something similar to the same file for passwordless consoles . And then ofcourse modify my inittiab to get rid of those CPU/memory wasting consoles ... |
|
Back to top |
|
|
nanodust n00b
Joined: 23 May 2007 Posts: 2
|
Posted: Wed May 23, 2007 2:05 am Post subject: simple. basic. easy. autologin. no gdm. |
|
|
1) emerge mingetty
2) edit /etc/inittab, replace normal line with
1:2345:respawn:/sbin/mingetty --autologin root tty1
3) if you also want to startx, not simply auto-login, then edit/create
~/.bash_profile
if [ `tty` = "/dev/tty1" ]; then
startx
fi
note those are backticks around tty, not quotes.
that's it!
it's quick & dirty, but works great !!! |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Wed May 23, 2007 7:53 am Post subject: Re: simple. basic. easy. autologin. no gdm. |
|
|
nanodust wrote: | it's quick & dirty, but works great !!! |
I guess I haven't updated this in a while. Autologin consoles can be done using agetty itself. All you have to do is replace the login program (using -l) with a shell script that does "login -f <username>".
Starting X should probably be done using local.start too. I'll edit my original post to show this.
GI |
|
Back to top |
|
|
swimmer Veteran
Joined: 15 Jul 2002 Posts: 1330 Location: Netherlands
|
Posted: Wed May 23, 2007 12:20 pm Post subject: |
|
|
I'm using it the same way nanodust describes above and am very happy with it since it works without glitches and is little hassle to setup
Greetz
swimmer |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Wed May 23, 2007 6:37 pm Post subject: |
|
|
The reason I ddn't use nanodust's method is because it results in tty1 "dead" (with just error messages from startx), and another tty used by X. Plus when I tried mingetty, I got some wierd message about "ioctl() failed, job control will be disabled" every time tcsh ran. Thus the agetty solution...
I also like ktm's suggestion about using local.start for starting X.
GI |
|
Back to top |
|
|
Abecedarian n00b
Joined: 14 Jan 2007 Posts: 40
|
Posted: Thu May 24, 2007 11:35 am Post subject: |
|
|
You can also do it with a C program, a trick I've retained from my time on ArchLinux:
Code: | #include <unistd.h>
int main() {
execlp( "login", "login", "-f", "george", 0);
} |
Compiled it with
Code: | gcc -o autologingeorge autologingeorge.c |
and modified /etc/inittab to something like
Code: | c1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/autologingeorge 38400 vc/1 linux |
Straight outta ArchWiki. |
|
Back to top |
|
|
saFFyre n00b
Joined: 22 May 2004 Posts: 22
|
Posted: Sat May 26, 2007 9:29 pm Post subject: |
|
|
Hi, the local.start method is not working from me. It works if i do /etc/init.d/local start but not on boot. Any ideas? |
|
Back to top |
|
|
gi1242 Tux's lil' helper
Joined: 29 Jul 2004 Posts: 146
|
Posted: Sun May 27, 2007 9:39 am Post subject: |
|
|
saFFyre wrote: | Hi, the local.start method is not working from me. It works if i do /etc/init.d/local start but not on boot. Any ideas? |
What error message do you get? Something on stdout? Or something logged into your .xsession-errors?
Btw -- you have disabled your xdm from starting right?
GI
PS: Nanodust -- Your mingetty trick works wonderfully! I realize that if I called mingetty from the shell, it always gave me the "ioctl failed" junk error. But when called by init, it works great! |
|
Back to top |
|
|
ekz l33t
Joined: 21 Jun 2006 Posts: 994 Location: Temuco - Chile
|
Posted: Thu Oct 11, 2007 5:11 am Post subject: |
|
|
This worked for me (I modified a bit )
Code: |
### Start X as user if tty7 is free ###
if ! fuser /dev/tty7 >& /dev/null; then
su USERNAME -l -c startx -- vt7 >& '~/.xsession-errors' &
fi
|
thanks for the trick
SAludos! _________________ Mi tumblelog |
|
Back to top |
|
|
OnlyTux Apprentice
Joined: 15 Mar 2007 Posts: 174
|
Posted: Tue Aug 31, 2010 1:16 pm Post subject: |
|
|
Thank you very much for the trick.
I have a machine with LXDE, and with this script I can login immediately without problems.
I only have a little glitch: X starts in English and not in the right tongue. However, if I close the graphic session and then start X again from the auto-logged-in user terminal, everything is in the expected language.
The LANG variable is correctly configured, and I see no differences in the output of the env command inside the English and Italian sessions user xterms.
Does anybody know where I am wrong?
Thanks in advance for any hints.
Best regards. _________________ ANTONIO: How every fool can play upon the world! I think the best grace of wit will shortly turn into silence, and discourse grow commendable in none only but parrots...
Shakespeare, The Merchant of Venice |
|
Back to top |
|
|
Satoshi Apprentice
Joined: 06 Nov 2006 Posts: 180 Location: Brazil
|
Posted: Wed Sep 22, 2010 9:54 am Post subject: Re: Passwordless console / x user logins [Working] |
|
|
gi1242 wrote: |
First create the file /root/bin/autologin, and put the following in it:
Code: | #! /bin/bash
exec login -f <username> |
Make it executible via chmod a+x /root/bin/autologin.
Next modify your /etc/inittab: Replace the line
Code: | c2:12345:respawn:/sbin/agetty 38400 tty2 linux |
with
Code: | np2:12345:respawn:/sbin/agetty -l /root/bin/autologin -n 38400 tty2 linux |
|
Would login -f <username> be more resource-friendly than mingetty --autologin? |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1880 Location: Switzerland (Romandie)
|
Posted: Sun Dec 25, 2011 4:40 pm Post subject: Re: Passwordless console / x user logins [Working] |
|
|
I want to be able to login and startx, and to be sure than all my customizations in ~/.bash_profile and ~/.bashrc are enforced. I want it to be so less intrusive than possible and I want the user login on tty2.
gi1242 wrote: | The follwing will make the virtual consoles at boot time password-less (i.e. will be the login shell of your user, without requiring you to authenticate it):
First create the file /root/bin/autologin, and put the following in it:
Code: | #! /bin/bash
exec login -f <username> |
Make it executible via chmod a+x /root/bin/autologin.
Next modify your /etc/inittab: Replace the line
Code: | c2:12345:respawn:/sbin/agetty 38400 tty2 linux |
with
Code: | np2:12345:respawn:/sbin/agetty -l /root/bin/autologin -n 38400 tty2 linux |
|
Question: Is it a way to make the same but by using only /etc/local.d/local.start instead of modifying /etc/inittab that is already managed by portage?
EDIT: Stupid question. I am reading man inittab and it look like to be the right way to go anyway.
After, for launching startx, I modified ~/.bash_profile:
Code: | # start X
if [[ -z $DISPLAY && ! -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
exec startx
# while true; do
# read -p 'Veux-tu démarrer X? (o/n): '
# case $REPLY in
# [Oo]) exec startx ;;
# [Nn]) break ;;
# *) printf '%s\n' 'Stp réponds o ou n!' ;;
# esac
# done
fi
|
The commented out code will let you to choose if you want to run startx or login into the console. _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
Tin Guru
Joined: 22 Dec 2005 Posts: 305 Location: Namur, Belgium
|
Posted: Sun Nov 22, 2015 12:26 pm Post subject: Re: Passwordless console / x user logins [Working] |
|
|
First of all, thank you very much for that nice solution.
This part of the tutorial is not working for me.
gi1242 wrote: |
Edit /etc/conf.d/local.start and add the lines
Code: | # Start X as user if tty7 is free
if ! fuser /dev/tty7 >& /dev/null; then
su - <username> -l -c 'exec startx -- vt7 >& ~/.xsession-errors' &
fi |
Note: If you use tcsh, you should remove the -l flag.
If local is not part of your default runlevel, then add it:
Code: | rc-update add local default |
|
What I had to do is to create a file in /etc/local.d
which a filename finishing with .start
and the same content as yours
and its working
I choose to create file /etc/local.d/startx.start
Best regards and again thank you _________________ Tin, the gentoobie |
|
Back to top |
|
|
|