Solved Connect to opened virtual console via ssh

I have person, who sit before pc with opened virtual console
Can I connect to that pc via ssh and connect to the same console, so that I can enter commands and that person can see what I do?
 
No. A process always has one controlling terminal (in case of SSH, this is a "pseudo terminal" to allow forwarding to another machine where it's connected to a "real" terminal). You can't just "attach" to a different terminal used by a different process.

There's software like sysutils/tmux offering multiplexable pseudo-terminals including multiple clients attaching them, but then your user on the actual console must actively run tmux first.
 
The easy way is using screen/tmux.
Yep. I use these a lot. Open a new session, run a program/job/whatever. Disconnect the session, go home, pick up session again from home. Also quite useful to do remote updates when the connection isn't too stable. If you get disconnected you can just login and pick up the session again, nothing gets interrupted (which would be bad if this happens halfway during an upgrade).
 
I remembered that it was a simple way and I found it
as a root you can use watch -W
This can easily go wrong because of
Code:
BUGS
     No terminal emulation is performed.  All user output is reproduced as-is.

Also needless to say there's a reason this requires root privileges by default, it's a massive privacy breach (and potential security risk).

Edit: Also note this won't work at all in a kern.securelevel raised above 0 unless snp(4) is explicitly loaded at boot time. This tool just makes sense if your usecase is indeed "spying" on someone (without consent). For all other cases, I'd really recommend to use the "cooperative" (and, portable) approach with an actual terminal multiplexer like tmux, giving you lots of useful features, starting with the "terminal emulation" mentioned above and including being able to run completely "detached" as well.
 
Back
Top