use gnu screen when ssh'ed as a user, but su as another

To directly answer your question:

ssh [email protected] su grandplan -c “script /dev/null -qc \"screen\""

Don't change the permissions on your /dev/pts/X - it just introduces an unnecessary security hole.


Type script /dev/null before starting screen.

$ su - gradplan
$ screen
Cannot open your terminal '/dev/pts/15' - please check.
$ script /dev/null
Script started, file is /dev/null
$ screen
# do whatever inside the screen
[detached]
$

ref: ServerFault: Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?


If you:

ls -l /dev/pts/7

You will see it is owned by sbird, when you switch to gradplan, he doesn't have perms to touch that device.

You can try doing

chmod a+rw /dev/pts/X

(X being which pts # you are currently connected to, because it will change) before you screen.

Or you can screen as sbird, then in each screen window su there.