Using "screen -S sessionName .script" in SSH: Difference between revisions

From munkjensen.net/wiki
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
Often enough, one is logged in as root and decides to su – to an underprivileged user. Due to the tty for the root shell being owned by the user root, the su’d environment is unable to run screen:
Often enough, one is logged in as root and decides to su – to an underprivileged user. Due to the tty for the root shell being owned by the user root, the su’d environment is unable to run screen:


root@whitegirl:~# su - joe
<syntaxhighlight lang="xml" line>root@whitegirl:~# su - joe
joe@whitegirl:~$ screen
joe@whitegirl:~$ screen
Cannot open your terminal '/dev/pts/0' - please check.
Cannot open your terminal '/dev/pts/0' - please check.
joe@whitegirl:~$
joe@whitegirl:~$</syntaxhighlight>


This is resolved by setting the owner of the terminal device to the target user before running su, so the user then has write privileges on the pseudo teletype device:
This is resolved by setting the owner of the terminal device to the target user before running su, so the user then has write privileges on the pseudo teletype device:


root@whitegirl:~# chown joe `tty`
<syntaxhighlight lang="xml" line>root@whitegirl:~# chown joe `tty`
root@whitegirl:~# su - joe
root@whitegirl:~# su - joe
joe@whitegirl:~$ screen
joe@whitegirl:~$ screen</syntaxhighlight>


And then revert it when done
And then revert it when done


[screen is terminating]
<syntaxhighlight lang="xml" line>[screen is terminating]
joe@whitegirl:~$ logout
joe@whitegirl:~$ logout
root@whitegirl:~# chown root `tty`
root@whitegirl:~# chown root `tty`
root@whitegirl:~#
root@whitegirl:~#</syntaxhighlight>
</div>
</div>
</div>
</div>
[CTRL+a] then [d] will detatch you from the screen-session.
----
General info about 'screen' can be found [https://packages.debian.org/stretch/screen here].
A nice guide can be found [https://nathan.chantrell.net/linux/an-introduction-to-screen/ here].


[[Category:Debian]]
[[Category:Debian]]

Latest revision as of 16:01, 27 June 2017

If you get Cannot open your terminal '/dev/pts/0' - please check. look here :-)

Credit to http://debianaddict.com/

Often enough, one is logged in as root and decides to su – to an underprivileged user. Due to the tty for the root shell being owned by the user root, the su’d environment is unable to run screen:

root@whitegirl:~# su - joe
joe@whitegirl:~$ screen
Cannot open your terminal '/dev/pts/0' - please check.
joe@whitegirl:~$

This is resolved by setting the owner of the terminal device to the target user before running su, so the user then has write privileges on the pseudo teletype device:

root@whitegirl:~# chown joe `tty`
root@whitegirl:~# su - joe
joe@whitegirl:~$ screen

And then revert it when done

[screen is terminating]
joe@whitegirl:~$ logout
root@whitegirl:~# chown root `tty`
root@whitegirl:~#

[CTRL+a] then [d] will detatch you from the screen-session.


General info about 'screen' can be found here.

A nice guide can be found here.