The FreeBSD 'zine
March 2000 : Snoop

Just Snooping Around...
by Jamie Hermans <[email protected]>

Why?

Being relatively new to FreeBSD, I have inadvertently taken it upon myself to share what I have learned through trial and error with others. Where I work, there are a number of us who have taken the leap of faith into the versatility of FreeBSD. With more and more friends and co-workers deciding to take a stab at it almost monthly now, I find myself doing a lot of "favors" after someone has done the initial installation. While I do not mind helping out in the least, I find it hard to tell someone what I'm doing to their computer (via SSH) while they stare blankly at the prompt. And saying "This will only take a sec..." and then having "magically" fixed whatever their problem was, is NOT a way to train people. Hence, my quest for a training assistant began ... enter "watch" and "snp".

By adding one line to the FreeBSD kernel recompiling and adding a few devices, you enable "snooping" on a server. Anyone logged in as (or su'd to) root can watch any other active session. This is great for literally walking someone through an install of the "latest port" or fixing that stubborn error message.

I should mention that this works for terminal sessions only ... as well a "bug" to take note (as per the man page): "No terminal emulation is performed. All user output is reproduced as-is." Sometimes a vi or ee editing session can look really bizarre if both users are not using the same emulation and screen dimensions.

How? (Part A)

Once logged into the "to be trained on or fixed" computer, change to root if you are not already. You need to make a few devices for the snp device. However many devices you make, is how many you need to specify in the kernel configuration (for example purposes, I am using three devices.)

Change to /dev and make the new devices:

	# cd /dev
	# sh MAKEDEV snp0 snp1 snp2

Edit your current customized kernel (or start customizing one now):

	# cd /usr/src/sys/i386/conf
	# vi KERNELNAME

Add this line in somewhere with the rest of the pseudo-devices:

     pseudo-device    snp    3   # Snoop device - to look at pty/vty/etc..

Compile the kernel, make dependencies, make and install the kernel, and reboot:

	# /usr/sbin/config -r KERNELNAME
	# cd ../../compile/KERNELNAME
	# make depend
	# make
	# make install
	# reboot

That's all there is to installing it. Now to actually use the teaching aide.

How? (Part B)

You will need to log into (as root, or become root on) the remote server. Have your assistant (person needing your expertise) log into their server as root (or su to root) as well. They will need to find out what session (tty name/number) that YOU are logged into:

	# who
	root             ttyp0   Feb 27 19:59   (remote)

Assuming you are on session ttyp0 (as in the above example), they would simply type:

	# watch ttyp0

Anything you now do in your session will be mirrored on their session. If you are both using the same emulations and screen dimensions, then everything "should" look identical. At this point, your assistant is effectively locked out of their keyboard, except for a few crucial keystrokes:

  • CTRL-Gwill disconnect from the viewer.
  • CTRL-Wwill clean the screen.
  • CTRL-X will change the attached session.

Obviously, viewing your own session is silly (yes, it works... no, you don't see anything). There is a way to work interactively with the session you are viewing (i.e., your assistant could enter passwords, preferences, etc.) but I'll leave that to you to discover (hint: man watch).

I hope this helps someone as much as it has helped me - I know that I use it quite often lately!

- Jamie


Jamie Hermans was inaugurated into the FreeBSD in early 1999. Originally intending to set up a simple web server "just for fun", Technically Speaking Computer Services (TSCS) was born and now hosts other domains for email, DNS and web services.

Sharing information is the key to learning and expanding on your own knowledge. TSCS does this by helping others setup and configure FreeBSD servers for personal use (home firewall-gateway solutions) and for small business use (file sharing, firewall-gateway, DHCP, web and ftp services, etc.) This article is just one of many ways Jamie uses to "share the information".

Current Issue
. Issue #06 : July 2000

Old Issues
. Issue #01 : February 2000
. Issue #02 : March 2000
. Issue #03 : April 2000
. Issue #04 : May 2000
. Issue #05 : June 2000

Quick Links
. Table of Contents
. Mailing Lists
. FreeBSD Events
. User Group Calendar
. Site Statistics
. Old Articles
. Latest News
. Press Releases
. Contribute
. Send us Feedback
. Other Resources
. Submit an Article
. Submit an Event

Today's Fortune
A truly wise man never plays leapfrog with a unicorn.

FreeBSD 'zine Poll
Are you going to BSDCon?
Yes.
No.
Maybe.
What the hell is BSDCon?
Results More polls

Sponsors
. VicFUG

Download
. Issue #01 : Download
. Issue #02 : Download
. Issue #03 : Download
. Issue #04 : Download
. Issue #05 : Download
. Issue #06 : Download

Search

Runs on FreeBSD

Add Channel to My Netscape

DaemonNews

Contact: <[email protected]>
This site and the tarballs are built every 6 hours.
Copyright � 1998-2000, The FreeBSD 'zine
Code revision: 07/24/2000��All rights reserved.