Linux 终端:如何捕获或观看其他终端会话

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1353253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:39:36  来源:igfitidea点击:

Linux Terminal: how to capture or watch other terminal session

linuxterminal

提问by user149513

Let say, I access to a server using ssh. In the same time, there is another person accessing that server.

比方说,我使用 ssh 访问服务器。同时,还有另一个人访问该服务器。

Is it possible to watch what is going on in that person's terminal. Meaning, Can I just watch what he is typing?

是否可以观看该人的终端中发生的事情。意思是,我可以看看他在打什么吗?

采纳答案by Martin v. L?wis

If the other person is using the Linux console, you can use conspy.

如果其他人正在使用 Linux 控制台,您可以使用conspy

回答by Ryan C. Thompson

If you mean that the other person wantsyou to see his console, you two can use screen to share a terminal. See http://www.gnu.org/software/screen/manual/html_node/Multiuser-Session.htmlfor a full description of how to do it.

如果你的意思是对方想让你看到他的控制台,你们两个可以使用 screen 来共享一个终端。有关如何执行此操作的完整说明,请参阅http://www.gnu.org/software/screen/manual/html_node/Multiuser-Session.html

回答by Patrick

You can also try "cat /dev/vcsa1"

你也可以试试 "cat /dev/vcsa1"

回答by Coder of Salvation

Well depending on whether its for 'live' or 'ondemand' purposes, you could replay it online with a service like www.playterm.org.

好吧,取决于它是用于“实时”还是“按需”目的,您可以使用www.playterm.org 之类的服务在线重播。

回答by Maze

You can use the small tool scriptfor logging the terminal into a file. The observing party can simply tail -fthat file to follow.

您可以使用小工具脚本将终端登录到文件中。观察方可以简单地对要跟​​踪的文件进行tail -f

This is a much simpler approach, but it works very nicely for most cases

这是一种简单得多的方法,但在大多数情况下效果很好

回答by estani

I also use an approach similar to what Maze said. This is a unidirectional sharing with read-only for the guest. This is how it works:

我也使用了类似于迷宫所说的方法。这是访客只读的单向共享。这是它的工作原理:

1) The host starts the scriptcommand writing somewhere where the guest has read access and set the permits as required, for example:

1)主机script在guest有读访问权限的地方开始写入命令并根据需要设置许可,例如:

$ script -f /tmp/shared_screen
Script was started....
$ chmod 640 /tmp/shared_screen
$ chgrp shared_group /tmp/shared_screen

The -fflushes the contents permanently so you'll have a very low delay

-f永久刷新内容,这样你就会有一个非常低的延迟

2) The guest starts dumping the content of the file:

2) 来宾开始转储文件内容:

$ tail -f /tmp/shared_screen

In this case -fcauses tail to wait on more output from the file. Use ctrl-Cto stop displaying the file contents.

在这种情况下,-ftail 会等待来自文件的更多输出。使用ctrl-C停止显示该文件的内容。

回答by Benji York

If you want to share a session on a machine behind a firewall or NAT, you can use the open-source terminal sharing program Termbeamer.

如果要在防火墙或 NAT 后面的机器上共享会话,可以使用开源终端共享程序Termbeamer

回答by David Cary

To capturewhat Alice types in a terminal, and then the next day let Bob see what was typed -- without any risk of Bob accidentally typing anything into that terminal -- Alice can type "showterm" ( http://showterm.io) in her terminal window to start the recording.

捕获Alice 在终端中键入的内容,然后第二天让 Bob 查看键入的内容——没有 Bob 不小心在终端中键入任何内容的风险——Alice 可以键入“showterm”(http://showterm.io)在她的终端窗口中开始录制。

To sharea terminal so Alice and Bob both see "the same" terminal window and can both type commands into that window, there seems to be three popular methods: Byobu, tmux, or screen.

共享一个终端,以便 Alice 和 Bob 都能看到“相同”的终端窗口并且都可以在该窗口中键入命令,似乎有三种流行的方法: Byobutmuxscreen

(tmateis a fork of tmux that works just as well, perhaps better).

tmate是 tmux 的一个分支,它也能正常工作,也许更好)。

回答by Roberk20

Something nice and easy:

一些美好而简单的事情:

watch -n 1 cat /dev/vcsa1

watch -n 1refers for the time to refresh.

watch -n 1指刷新的时间。