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!):
#!/bin/bash# $1 = [remote_user@]remote_host# $2 = [alias name]BIN=$HOME/binif [ "$#" -lt 1 ] || [ "$#" -gt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; thenecho "Usage: $0 [user@]machine [alias]" >&2exit 1fiif [ "$#" -eq 2 ]; then(cat <<EOF
#!/bin/bashssh $1 -t screen -x -REOF) > $BIN/$2chmod u=rwx,go= $BIN/$2fissh-copy-id -i ~/.ssh/id_rsa.pub $1 > /dev/null 2>&1scp ~/.screenrc $1:~/ > /dev/null 2>&1exit 0
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:
Macnux:~ carlos$ setup-machine -hUsage: /Users/carlos/bin/setup-machine [user@]machine [alias]Macnux:~ carlos$ setup-machine cgoncalves@cgoncalves.info cgoncalvescgoncalves@cgoncalves.info’s password: *****************Macnux:~ carlos$ cat bin/cgoncalves#!/bin/bashssh cgoncalves@cgoncalves.info -t screen -x -RMacnux:~ carlos$ cgoncalves[SSH connection established and attached to screen]
2 comentários:
Convite para hackmeeting no Porto
http://hackmeeting.hacklaviva.net
28,29 e 30 de Outubro de 2011
O primeiro hackmeeting em Portugal, a juntar hackers por toda a Península Ibérica.
Lovely blog you have heree
Post a Comment