Part of my daily routine involves accessing and managing a considered amount of remote servers through the SSH protocol. I use screen a lot to ease the job by having a couple of windows opened on each server, so avoiding multiple connections to the same server. By using screen not only helps me grouping server windows altogether in one console window/tab but also is a time saver in those days when network connection is not in its glory days allowing me to reattach it and carrying on being productive (sighs).
But, before connecting to all those machines, I used to repeat over and over the same setup steps:
- send my public key to server
- upload my screen configuration file
- create an alias (because ssh’ing manually is a truly hassle each time I want to connect!) to connect to the server and reattach or create a new screen session
- Change its permissions to 700 (security freak? Oh well…)
Four repetitive and forgettable operations that could all be avoided, sparing me some minutes of my precious time. But no more!
Here is a handy Bash script I wrote the other day (at last!):
Copy and paste this code to a file in your $PATH (mine is $HOME/bin/setup- machine) and give it execution permission (chmod u=rwx,go= ).
Obvious to some, though may not be to others, here is an usage example: