Creating one "per-user" login script on Ubuntu server

Discussion in 'HOWTO-Related Questions' started by awe, May 6, 2009.

  1. awe

    awe New Member

    Hello,

    Is it possible to create a bash script that Ubuntu Server will execute every time that a user logs in locally? Is it possible to set up a specific script for each user?

    I explain. For the reasons that I explain on this post, I need that users listed on the LDAP tree cannot log into the server machine (please read the post for more details).

    Would it be possible to create a bash script for the users that I want to lock out of the server, so that this script would log them out? I mean, a login script that would contain "logout" as the first (and probably the only) order, so that the users from the LDAP tree would pass authentication but then be kicked out more or less immediately.

    How can I do that?

    Thanks, and regards,
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Why don't you give these users a shell such as /usr/sbin/nologin or /bin/false? Then they wouldn'T be able to log in via SSH.
     
  3. awe

    awe New Member

    Hello Falko,

    I really would not want to mess something and not be able to log into my server box at all, so, because I have never changed the default shell, could you please indicatme precise instructions for changing the shell on a per-user basis? Or maybe point me somewhere on the internet where I can find those instructions? It is important to remind that the user that I created at install time should be allowed to log in, but just not the others.

    I have found a number of posts and web pages talking about such a change on Ubuntu desktops, but not so for servers.

    Your idea seems to me like a perfect solution.

    Million thanks for your help.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Just edit the /etc/passwd file.
     

Share This Page