Skip to content

Instantly share code, notes, and snippets.

@niczero
Last active January 25, 2019 13:53
Show Gist options
  • Save niczero/68769aed4588ac096825d7f5d851434b to your computer and use it in GitHub Desktop.
Save niczero/68769aed4588ac096825d7f5d851434b to your computer and use it in GitHub Desktop.
Giving root access to non-root screen session
  1. Create a virtual user.
  2. Provide that user access to a screen window file.
  3. Create their screen session.
  4. Grant access for root.

Bonus 5. Create a vim session file.

Screen window file

eg /etc/screen.dev.lst for a development list of windows.

screen -t vim
screen -t git
screen -t log
screen -t job
screen -t db

and make it world readable

chmod 0444 /etc/screen.dev.lst

Create their screen session

eg for the virtual user 'feed' and the project 'proj123':

mkdir /srv/proj123
chown feed:feed /srv/proj123
su - feed
cd /srv/proj123  # 'home' for this project
script /dev/null  # work around tty for virtual user
. /opt/perl/5.28.1.env  # set up whatever env
export PERL5LIB=$(pwd)/lib:/srv/feed/v6/lib/perl5
screen -c /etc/screen.dev.lst -S proj123

then test exit/reentry with <ctrl><a>, <d> then

screen -dr proj123

Grant access for root

In the session as feed

Set multi-user: <ctrl><a> then :multiuser on. Grant access: <ctrl><a> then :acladd root. Then <ctrl><d> repeatedly till you are back as 'root'.

Now back in the shell as root

You should be able to see the session is available via

screen -ls feed/

and then enter the session with

screen -dr feed/proj123

ToDo Set a password!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment