By editing the /etc/sudoers
configuration file, you can configure sudo
to allow one user to run commands as another user. In particular, you can use sudo
to allow one user to launch a shell as another user. For example, the following line allows user
run bash
as lowp0
:
user ALL=(lowp0) /bin/bash
You should then be able to do something like the following:
user@host:~$ sudo -u lowp0 bash
lowp0@host:~$
You could also use the su
command in place of bash
:
user ALL=(lowp0) /usr/bin/su -l
To allow access to both users via both commands, you could add the following lines:
user ALL=(lowp0,lowp1) /bin/bash, /usr/bin/su -l
If you're running an SSH server, you could also add the public key of user
to the ~/.authorized_keys
files of lowp0
and lowp1
. This should allow user
to ssh
into localhost as either of these users, e.g.:
user@host:~$ ssh lowp0@localhost
lowp0@host:~$
sudo
andssh
. Consider that you may not need to change user. You can set permissions on a file so that another user can access/write to it. see https://unix.stackexchange.com/q/101263/4778 – ctrl-alt-delor May 23 '18 at 10:15