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
fish:x:1001:100::/home/fish:/bin/bash
and /etc/group contains
users:x:100:
sudo:x:27:gsluser,fish
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
users
$ 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?
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.