mirror of
https://github.com/ovh/the-bastion.git
synced 2026-05-09 08:25:27 +02:00
[GH-ISSUE #361] Unable to "logout" to have your new rights applied #95
Labels
No labels
answered
bug
documentation
enhancement
enhancement
feature
feature
kept-open-for-info
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/the-bastion#95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @airmoi on GitHub (Feb 15, 2023).
Original GitHub issue: https://github.com/ovh/the-bastion/issues/361
Hi,
Yet another one !
After a user was added to a group, he has a notice each time he tries to run a command and is unable to access hosts within that group :
I tried to exit then log back again, lock the session... but it persists, how are we supposed to "logout" from an interactive session ? I couldn't find any information in the documentation
@speed47 commented on GitHub (Feb 15, 2023):
Hello,
You can just type "quit", or "exit", or CTRL+D, all three work to end your interactive session. You can also type "help" in the interactive session, which will give you the list of plugins, and also a few interactive-specific commands (such as "quit") :)
@airmoi commented on GitHub (Feb 15, 2023):
I tried both exit/quit/^D commands but it remains
@speed47 commented on GitHub (Feb 15, 2023):
Okay, so 2 things are a bit strange:
bssh --osh -ishould not work:--oshexpects a plugin name as parameter (for example:bssh --osh info), and obviously-iis not a plugin name, so you should get an "Unknown command" error, instead of entering interactive session. If you did type this command and ended up in interactive session, could you paste yourbsshalias, aka the output of thetype bsshcommand?You definitely should not get the "you've been added to new groups" message when entering a new interactive session. I've just pushed a test branch on
test-issue-361which adds some debug, so I can better understand what's causing it on your system. It just has one commit on top of the current main branch, could you just git checkout your system to it, redo the steps where you end up with this message, and post the debug you have? A short howto follows:On your bastion server, as root:
Then, enable debug mode for your account, for example if your bastion account name is "user", toggle debug this way:
You should then notice that you'll get far more output when using the bastion as "user".
Once you're done, to disable debug mode, use the command again but by specifying "off" instead of "on".
Don't forget to rollback the code to the version you were using previously, I'm assuming you were using the latest stable tagged version:
The interesting part on the debug output will be there:
@airmoi commented on GitHub (Feb 15, 2023):
Hi,
My mistake, I used only
-ioption to log into interactive mode as stated here https://ovh.github.io/the-bastion/using/basics/first_steps.html#pluginsHere is the debug output :
I just created a new group and add my user to this group then connect with this user using
bssh -ito enter interactive mode then typeinfo.Also I figure out using
bssh --osh infodoes not produce this message@speed47 commented on GitHub (Feb 16, 2023):
First things first, this is normal that you only get this message in interactive mode, it'll never appear anywhere else, because the issue it's warning you about can only happen in interactive mode.
Did you start the interactive session after the user was added to the group? (I think this is the case reading your message, but I want to be extra-sure).
Just to give you more context about the existence of this message: when you add some user to a bastion group, several things happen, and among those, this user is added to a Linux system group which represents the bastion group. Namely, if the bastion group is "test1", the user will be added to the system group "keytest1".
When you are in interactive mode, there's a process server-side (bastion-side) started under your Linux account user (representing your bastion user), and this process is alive as long as the interactive session is up. If you've been added to a new bastion group, your system user is added as a member of the Linux system group representing this bastion group. Under Linux, all processes running under a user that were started before the user was added as a member to a system group will NOT see that the user they're running under is now part of a new group. This is how Linux works, and AFAIK there is no way to "tell" this updated information to the already started process, i.e. the kernel will continue acting as if these preexisting processes have no access to the new group. This is also true for any new processes started by these processes (forking). The only way to "update" this information is to terminate the process and start it again (where it'll "see" the new group).
The message you're seeing is an heuristic to try to detect this case (i.e. your current user's group memberships have been changed since the interactive session was started), and it's just reminding you that if you try to use commands that do require the new memberships, these commands will fail because the interactive session doesn't have the required group memberships, as far as the Linux kernel is concerned. You have to exit and enter it again. Any other commands will work normally.
So far, I've never witnessed a system where this heuristic fails, and it seems to be the case on yours (if you confirm that you get this message even after entering a fresh interactive session). Technically, it means that the output of the command
id -G -n youruseris different from the output ofid -G -n(when ran as youruser), which should only be the case if you're runningid -G -nfrom a shell that was started BEFORE you've been added to a new system group, as explained above.What OS/distro/version are you using btw? Do you have setup anything special around the Linux user/group management, or PAM?
@airmoi commented on GitHub (Feb 16, 2023):
OS is Ubuntu 22.04, an OVH fresh install. I installed git first to clone the project and run the install process.
For more clarity, lets call the user
totoAs all steps were run in the same terminal session, I logged in as admin, created the group, added
tototo the group, logged off, then logged in astotoin interactive mode. This session should have been created after the user was added to the group.However, I had connected to
totosession some time before and I think this session process was never ended/killed when I exited. When I re-logged in, it seemed to reuse the old session process (which is the root cause, in my opinion, as this session was created before the user was added to the group).As root, I performed a
ps -aux | grep toto(while no interactive session was running). Here is the output:I killed the two sshd processes and was able to re-login, solving the issue.
I can provide access to the bastion if you want, as it is only a test server with no sensitive data.
@speed47 commented on GitHub (Feb 17, 2023):
Interesting, as we don't use Ubuntu 22.04 in prod for bastions, maybe this is some new behavior on their side regarding sshd, will try to reproduce. This behavior wouldn't be catched by our integration tests (which do include Ubuntu though)
@speed47 commented on GitHub (Feb 17, 2023):
Just tried with a sandbox on Public Cloud with Ubuntu 22.04, and I can't seem to reproduce your issue. On my system, when toto disconnects, the server-side processes correctly go away (except systemd-user and sd-pam but that's expected).
Indeed the 2 processes you see after toto has disconnected should not be there, and in any case, should not be "reused" when toto connects!
Do you have a specific setup on your workstation regarding your SSH client? It seems that for some reason, the connection seems to stick after you exit. Can you check that your SSH client on your workstation has indeed completely exited when you exit interactive mode?
@airmoi commented on GitHub (Feb 23, 2023):
I have fig installed and also using zsh/Oh my zsh, perhaps one of these is responsible for the persistence of the session then.
I'll try to figure out which one is the culprit (if any) and also try using another "clean" workstation to see if that's the problem.
Thank you for taking the time to help me
@airmoi commented on GitHub (Mar 9, 2023):
Finally I found the culprit !!
My
.ssh/confighad theControlPersist yesoption set for all server of my domain (can't remember why/when I set this)However removing this option solves the issue
@speed47 commented on GitHub (Mar 16, 2023):
Ah, nice! Thanks for the followup!