Get a "full" shell for another user that allows using podman/systemd
1
vote
4
answers
673
views
I log in wish SSH as one user "Ubuntu" on a server. I however want to manage run some systemd services as another user "ABC".
If I try to
sudo -u abc bash
as user ABC
then every systemd --user
command gives the error:
Failed to connect to bus: No medium found
I found [this thread](https://unix.stackexchange.com/a/245866/367146) which suggested adding the following to ~/.bashrc
:
export XDG_RUNTIME_DIR="/run/user/$UID"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
This changes the error to:
Failed to connect to bus: No such file or directory
Other sources suggested that headless servers don't normally have dbus installed so this makes sense (it appears to be a component of x11). Though I don't know why it works without issue if I run it as ubuntu
.
I found this [Suggested Workaround](https://unix.stackexchange.com/a/685029/367146)
sudo systemctl -M abc@ --user restart foobar.service
This works for basic start
, stop
, status
but:
* systemctl --user cat
doesn't work
* No variation of journalctl
seems to work:
Failed to open root directory of machine 'abc@': The name org.freedesktop.machine 1 was not provided by any .service files
Failed to open journal: No route to host
* It is just very long to type and inconvenient.
I really just want a shell for this other user just like when I log into ubuntu
and can manage all my user services with no issue.
I mention Podman because Podman also is really unhappy when I run it as a different user. It works fine if I use it as ubuntu
but get erors if I run it with sudo -u
. Like systemd I have some partial workarounds but none seem to work well.
Asked by mousetail
(113 rep)
Oct 20, 2024, 12:58 PM
Last activity: Jan 20, 2025, 12:29 PM
Last activity: Jan 20, 2025, 12:29 PM