Tuesday, January 29, 2013

an advanced usage of screen

The following script is an advance usage of command screen, which allows us to connect to a list of machines with few keystrokes (if key-based ssh logins is enabled). This is quite handy if we need to manage a long list of servers from our desktop.

#!/bin/bash
screen -d -m -S srvA   ssh serverA.domain.name

screen -d -m -S srvB   ssh serverB.domain.name
screen -d -m -S srvZ   ssh serverZ.domain.name

where options
-d -m        creates a new screen session in  detached mode
-S srvA  names identify of the session with the name srvA


To work on srvB, you just attach to its screen by typing:

screen -r srvB

No comments:

Post a Comment