Chinaunix

标题: 如何看到远程用户操作的命令? [打印本页]

作者: hardway_lin    时间: 2008-09-24 17:19
标题: 如何看到远程用户操作的命令?
有时候在linux平台上遇到故障,需要对方工程师远程ssh协助。

那我在本地,如何能看到对方操作的详细情况,即我可以看到他输入了什么命令,产生哪些输出?

linux下有没有这样的工具呢?

请教。
作者: maitr    时间: 2008-09-24 17:26
让他用screen
作者: hardway_lin    时间: 2008-09-24 17:44
screen是什么工具?
作者: hardway_lin    时间: 2008-09-24 17:47
我自己研究出来了
cat /dev/pts/1 >> /tmp/pts1.log
然后
tail -f /tmp/pts1.log
就行了
作者: vermouth    时间: 2008-09-24 18:01
lz的办法是实时的么?
作者: hardway_lin    时间: 2008-09-24 18:12
是实时的,不过没尝试过多个remote用户登录的情况
作者: lemoncookie    时间: 2008-09-24 21:55
标题: 回复 #2 maitr 的帖子
screen是个很好的工具
参见http://www.ibm.com/developerwork ... /index.html?ca=drs-
我把其中有用的一段摘出来了
Trick 3: Collaboration with screen
David, the high-maintenance user from product engineering, calls: "I need you to help me understand why I can't compile supercode.c on these new machines you deployed."
"Fine," you say. "What machine are you on?"
David responds: " Posh." (Yes, this fictional company has named its five production servers in honor of the Spice Girls.) OK, you say. You exercise your godlike root powers and on another machine become David:
# su - david
Then you go over to posh:
# ssh posh
Once you are there, you run:
# screen -S foo
Then you holler at David:
"Hey David, run the following command on your terminal: # screen -x foo."
This will cause your and David's sessions to be joined together in the holy Linux shell. You can type or he can type, but you'll both see what the other is doing. This saves you from walking to the other floor and lets you both have equal control. The benefit is that David can watch your troubleshooting skills and see exactly how you solve problems.

At last you both see what the problem is: David's compile script hard-coded an old directory that does not exist on this new server. You mount it, recompile, solve the problem, and David goes back to work. You then go back to whatever lazy activity you were doing before.
The one caveat to this trick is that you both need to be logged in as the same user. Other cool things you can do with the screen command include having multiple windows and split screens. Read the man pages for more on that.
But I'll give you one last tip while you're in your screen session. To detach from it and leave it open, type: Ctrl-A D . (I mean, hold down the Ctrl key and strike the A key. Then push the D key.)
You can then reattach by running the screen -x foo command again.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2