I don't acquire supplemental groups at login

I have ssh access to a fresh installation of Ubuntu 22.04 on a cloud VM. My password entry is


and /etc/group contains


When I log in, I get sh rather than bash and I’m not automatically in the sudo group, although groups says that I should be. If I newgrp into sudo, I get both:

$ groups
$ groups fish
fish @ users sudo
newgrp sudo
$ groups
sudo users

I can see nothing odd in any of the various profile and bashrc files and sshd.conf is unchanged since installation. Can anyone explain this behaviour?

Asked By: seismofish


From the comments to the question, it is clear that you are connecting to the remote system over a preexisting shared SSH connection using SSH connection sharing.

When you use SSH connection sharing (see the documentation for the -M and -S command line options in the ssh(1) manual, as well as the explanation of ControlMaster and ControlPath and related configuration options in the ssh_config(5) manual) the remote shell is spawned from a single remote session. It is when this single remote session is created that the secondary group(s) and other attributes are established, and these will remain in place and be duplicated for every further connection made via the same shared SSH connection.

This is why the new secondary group (and login shell) is not in effect when you log out and log in again.

The solution is to either connect without using the shared SSH connection,

ssh -S none remotehost

… or by forcing the connection to terminate with

ssh -O exit remotehost

… and then establishing a new connection to the remote host.

Answered By: Kusalananda
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.