Change default shell when user not in /etc/passwd

13,246

Solution 1

Hold on, it's an LDAP user, there is a setting in LDAP that allows you to change the default shell for the user in them.

You can install ldap-account-manager which gives you an webfrontent for the ldap configuration.

apt install ldap-account-manager

enter image description here

This can be done on any server which you want to handle the configuration on. Since you will need to configure the server in the config files anyway. But I would recommend you install it on the server which has the ldap actually running, just so you can remember it easier.

Solution 2

Here is a hint : /usr/bin/chsh.ldap: "/usr/bin/fish" is an invalid shell. It seems that you should add /usr/bin/fish to /etc/shells.

Share:
13,246

Related videos on Youtube

Abhishek Bhatia
Author by

Abhishek Bhatia

"The purpose of computing is insight, not numbers."- Richard Hamming, 1961 Abhishek has had a unique interdisciplinary research exposure to AI systems. His projects range from designing artificially intelligent autonomous systems that operate in varied setups, all the way to studying common emergent phenomena in natural systems. He has published 5 research papers in the field of complex systems, artificial intelligence and statistical inference. He is currently working on Deep Reinforcement Learning applications for Natural Language Processing and General-game Playing. He is also enthusiastic about open-source tools and frequently contributes to many open-source projects.

Updated on September 18, 2022

Comments

  • Abhishek Bhatia
    Abhishek Bhatia over 1 year

    Any ideas on how can I change the shell to fish?

    $ sudo usermod -s /usr/bin/fish jaan
    usermod: user 'jaan' does not exist in /etc/passwd
    $ getent passwd $USER
    jaan:x:15466:94:Jaan A:/home/jaan:/bin/zsh
    

    Related questions: user does not exist in /etc/passwd when trying to change the default shell Seems like it uses ldap.

    $ cat /etc/nsswitch.conf
    passwd:         compat ldap
    group:          compat ldap
    shadow:         compat ldap
    
    # Having the NOTFOUND=return bit was breaking dns resolution on web1 and web2. But we probably
    # don't want any of the mdns stuff so let's get rid of it all.
    #hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
    hosts:          files dns
    
    networks:       files
    
    protocols:      db files
    services:       db files
    ethers:         db files
    rpc:            db files
    
    netgroup:       ldap
    automount:      ldap
    

    So I installed ldap relevant package.

    $ chsh.ldap
    LDAP password for jaan:
    Enter the new value, or press ENTER for the default
      Login Shell [/bin/zsh]: /usr/bin/fish
    Traceback (most recent call last):
      File "/usr/bin/chsh.ldap", line 69, in <module>
        constants.NSLCD_USERMOD_SHELL: shell,
      File "/usr/share/nslcd-utils/nslcd.py", line 128, in usermod
        assert con.get_response() == constants.NSLCD_RESULT_BEGIN
      File "/usr/share/nslcd-utils/nslcd.py", line 103, in get_response
        return self.read_int32()
      File "/usr/share/nslcd-utils/nslcd.py", line 71, in read_int32
        return _int32.unpack(self.read(_int32.size))[0]
    struct.error: unpack requires a string argument of length 4
    $ which fish
    /usr/bin/fish
    $ chsh.ldap
    LDAP password for jaan:
    Enter the new value, or press ENTER for the default
      Login Shell [/bin/zsh]: "/usr/bin/fish"
    /usr/bin/chsh.ldap: "/usr/bin/fish" is an invalid shell
    $ /usr/bin/fish
    (standard_in) 1: syntax error
    Welcome to fish, the friendly interactive shell
    
    • George Udosen
      George Udosen over 6 years
      Is that even possible?
    • Abhishek Bhatia
      Abhishek Bhatia over 6 years
      @George please check edit.
    • George Udosen
      George Udosen over 6 years
    • Abhishek Bhatia
      Abhishek Bhatia over 6 years
      @George this doesn't work.
    • muru
      muru over 6 years
      The shell path should be in /etc/shells for chsh-like tools to accept it.
    • Abhishek Bhatia
      Abhishek Bhatia over 6 years
      @muru it's already there.
    • muru
      muru over 6 years
      @AbhishekBhatia is it? What exactly is in /etc/shells?
    • Ziazis
      Ziazis over 6 years
      In general you should not try to switch the default shell on the machine that uses ldap but on the server which has the ldap server running and which has the actual database for the users.
  • Abhishek Bhatia
    Abhishek Bhatia over 6 years
    Hmm..chsh works only if the user in /etc/passwd.$ chsh -s `which fish` Password: chsh: user 'jaan' does not exist in /etc/passwd
  • Max
    Max over 6 years
    Ah... yes... I did not see that part of it...
  • David Foerster
    David Foerster over 6 years
    That doesn't work when accounts are managed by LDAP. -1
  • jchook
    jchook about 6 years
    Haha lovely, chsh.ldap -s /usr/bin/zsh myusername gives me a Segmentation fault.
  • pim
    pim about 6 years
    Then it should be reported here : launchpad.net/ubuntu/+source/nss-pam-ldapd/+bugs