5

Since I've upgraded my server from Debian 8 to 9 I have a strange behavior with bash. When I log in via ssh, none of the profile files are loaded, I get the following prompt:

Linux myserver 4.9.0-7-amd64 #1 SMP Debian 4.9.110-1 (2018-07-05) x86_64
Last login: Mon Jul 16 22:37:12 2018 from x.x.x.x
-bash-4.4$

Running echo $0 returns -bash. I've put an echo "sourcing ..." line into /etc/profile, ~/.bashrc to see when they are invoked, but none of these lines are displayed. However, if I source these files manually, the text is displayed and the file is sourced as it should.

Using strace (found here) to see which files were open I see that all of the profiles files were open. echo exit | strace bash -li |& less | grep '^open'

I get the following output:

...
open("/etc/profile", O_RDONLY)          = 3
open("/etc/bash.bashrc", O_RDONLY)      = 3
open("/etc/profile.d/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/etc/profile.d/bash_completion.sh", O_RDONLY) = 3
...
open("/home/myuser/.bash_profile", O_RDONLY) = 3
open("/home/myuser/.bash_history", O_RDONLY) = 3
open("/home/myuser/.bash_history", O_RDONLY) = 3
...
open("/home/myuser/.bash_logout", O_RDONLY) = 3
open("/etc/bash.bash_logout", O_RDONLY) = -1 ENOENT (No such file or directory)
...

The problem only occurs when I log in as a normal user, once I su to root, the profile files are loaded as they should. I suspect that maybe only root has now permission to invoke the files, but I am going crazy as everything I checked is as it should be.

Any hint or idea is very much appreciated.

  • What does echo $SHELL report? Does your SSH configuration include ForceCommands for your user? – muru Jul 17 '18 at 1:42
  • $SHELL is /bin/bash, no ForceCommand included in ssh conf. – Sandor Farkas Jul 17 '18 at 5:59
3

Found the solution, which was around permissions as I suspected. Somehow the setgid bit was set on /bin/bash.

The left system is the one with the problem, the right is a working one: Solution

To solve the problem I run the following command:

   sudo chmod g-s /bin/bash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.