Sometimes it's useful to connect to many different lab machines at the same time. Having to type in your password or passphrase for each connection would be a pain.
ssh-agent is a program that stores your passphrase and provides it automatically for you when logging in.
Here's how I use
ssh-agent when I first connect to a CS machine (details explained below):
$ ssh-agent bash $ ssh-add Enter passphrase for .....: $ tmux
The above sequence runs
ssh-agent as the parent of the bash shell, so anything done in that bash shell uses the agent. I then add my ssh key to the agent, which stores it for future use. The last step isn't necessarily needed, but can be useful if opening up multiple terminals and windows (each subsequent window makes use of the ssh-agent with the stored ssh key included).
I usually do the above sequence in the first terminal I create when I log in. After that I can use
parallel-ssh or other programs to connect to multiple lab machines. Here's a simple example:
$ parallel-ssh -h /usr/swat/db/hosts.mainlab -i uptime  09:46:04 [SUCCESS] cheese 09:46:04 up 14 days, 12:23, 13 users, load average: 0.02, 0.05, 1.00  09:46:05 [SUCCESS] lime 09:46:05 up 14 days, 12:23, 0 users, load average: 1.00, 1.00, 1.00  09:46:05 [SUCCESS] mushroom 09:46:05 up 14 days, 12:23, 3 users, load average: 2.00, 1.08, 0.04  09:46:05 [SUCCESS] caper 09:46:05 up 14 days, 12:23, 0 users, load average: 1.00, 1.06, 1.00  09:46:05 [SUCCESS] bacon 09:46:05 up 14 days, 12:23, 0 users, load average: 1.00, 2.00, 2.00  09:46:05 [SUCCESS] basil 09:46:05 up 14 days, 12:23, 0 users, load average: 1.04, 1.01, 1.00 .... ....
In the example above I use
parallel-ssh to connect to all machines listed in
/usr/swat/db/hosts.mainlab (all machines in the main 240 lab), and I interactively (
-i) run the
uptime command (shows load, users, etc) on each machine.
Back to SwatCS Help Docs