Help support massadmin!
-c conf_file: commands list file. -e cmd_list : comma separated list of commands. -l srv_list : servers list file. -h host_list: comma separated list of servers. -d : debug mode. -o out_file : output result to a file. Default is stdout. -q nb_proc : change limit to nb_proc concurrent processes. Default: 15. -r dir : change running directory to dir. -p log_list : comma separated list of login:password pair to use.
I really recommand you to test with the -d option on a single computer the massadmin commands you will defined before running them on all you remote servers. Remember that untested commands can mass damage your servers especialy when they are run as root user!
Servers list file
You must set the -l command line option to specify the server list file to use to specify the remote hosts to connect to and the login/password pair to use.
Format of the server list file:
chdir:/jump/dir login:login1:login2:login3... password:pass1:pass2:pass3...
Note: All these configuration directives can be replaced with command line options to allow dynamic calls (using xargs for example).
Command line server list
You may want to specify dynamically the server list to massadmin, for that use the -h command line option. The value of this option is a comma separated list of hostname like in the servers list file.
massadmin -h "srv1.mydom.com:root:adm12,srv2.mydom.com:root:adm34"
or the same but using the global login/password definition with the -p option
massadmin -h "srv1.mydom.com,srv2.mydom.com" -p "root:adm12,root:adm34"
If you have a comma in you password, you have to add a backslash (\) before as well has the login/password colon separator ':'.
- Protocol can be: FTP,TELNET,RSH,SSH,SCP,SFTP - Authen is the "login;password" phrase. Separator is a semi-colon ';'. - command is any command handled by this protocol
Authen can be empty if you set login/password into the host list file.
FTP:ftpuser;ftppasswd:lcd /usr/tmp/:cd /usr/tmp:put foo.txt bar.txt: TELNET:username;userpassw:cd /home/foo:rm bar.txt: RSH:root:ls -la:
If you want to retrieve the output of a command just add a pipe at the end of the command, the result of the command will be added to the output stream:
RSH:root:ls -la: FTP:ftpuser;ftppasswd:lcd /ust/tmp/:cd /usr/tmp:ls -la|:bye: TELNET:usernam;userpassw:cd /home/toto:ls *.txt|:exit: SSH:usernam;userpassw:cd /home/toto:ls *.txt|:exit: # Local to remote (put) SCP:usernam;userpassw:local_source_file:remote_destination_file SCP:usernam;userpassw:local_source_dir:remote_destination_dir # Remote to local (get) SCP:usernam;userpassw::local_destination_file:remote_file SCP:usernam;userpassw::local_destination_dir:remote_dir SFTP:usernam;userpassw:cd /usr/tmp/:put foo.txt
All entries defined in the file are executed in the given order.
FTP::cd /usr/tmp/:del crontab.txt:del newcron.sh:put crontab.txt:ls | RSH::perl /root/change_network.pl| FTP::cd /home/someuser/:ls -la|:ls -la| TELNET::ls -la|:ps auxw | grep "named" | SSH::cd /home/someuser/:ls -la|:ls -la| # Local to remote (put) SCP::localarch.tar.gz:/user/tmp/localarch.tar.gz SCP::/opt/someApp/:/home/program/ # Remote to local (get) SCP:::/usr/tmp/localarch.tar.gz:localarch.tar.gz # Remote to local (recursive get) SCP:::/home/program/:/opt/someApp/
Here is how to do a su - as root user, the su - and root password is separated by a space character.
TELNET::su - RootPwd:ls -la | or SSH::su - RootPwd:ls -la |
In each command definition you can use the %SRVEXE_HOST special keyword, it will be replaced by the remote server hostname in which the command is executed. This is useful for example if you make backup and want to add the hostname into a filename.
Remember that the commands are passed to a Perl program (massadmin) so if you have special Perl characters like $ or other you need to escape them.
For example a call to a perl command to replace some string into a file must be written like that:
massadmin -h remotehost -p "root:admpasswd" -e "SSH::perl -p -i -e 's/cn\: ([^\\s]+) (.*)/cn\: \$2 \$1/' ldap-add.ldiff"
This command revert the first and last name in a LDAP ldiff file.
The normal perl command line substitution call would be:
perl -p -i -e 's/cn: ([^\s]+) (.*)/cn: $2 $1/' ldap-add.ldiff
Please always test your massadmin command before running it on mass hosts.
The authentication on remote servers can be defined at 3 different levels. Here are how they are used by massadmin in the order they will be executed.
In this example:
./massadmin -h "remotesrv.mydom:root:mdpadm" -p "admin:pass1,root:pass2" \ -e 'SSH:root;myadmpass:/usr/sbin/ether-wake 00\:25\:44\:DA\:43\:BF |:exit:'
The first authentication that will be tried is the one given in the SSH command, 'root;myadmpass'. If it fail or is not defined, this will be the one given in the remote server definition, 'root:mdpadm' and if it fail or is not defined here, massadmin will try each authentication defined in the -p command line option, 'admin:pass1' first and if it fail 'root:pass2'.
Copyright (c) 2002-2010 Gilles Darold - All rights reserved. (GPL v3).