Sudo as different user and running screen

gnu-screensudo

Found out today that running screen as a different user that I sudo into won't work!

i.e.

ssh bob@server         # ssh into server as bob
sudo su "monitor" -
screen                 # fails: Cannot open your terminal '/dev/pts/0'

I have a script that runs as the "monitor" user. We run it in a screen session in order to see output on the screen. The problem is, we have a number of user who logs in with their own account (i.e. bob, james, susie, etc…) and then they sudo into the "monitor" user. Giving them access to the "monitor" user is out of the question.

Best Answer

Try running script /dev/null as the user you su to before launching screen - its a ghetto little hack, but it should make screen happy.