Search This Blog

Thursday, March 22, 2012

Execute commands remotely from unix shell

 

The ssh command on linux does not support passing the passwords at the command line ,

You need to use the sshpass command. It is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode. You can install it as follows:

rpm –ivh ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/i386/sshpass-1.05-1.el5.i386.rpm

sshpass -p 'root-password' ssh -o StrictHostKeyChecking=no  root@localhost " du  --exclude=/shared  --exclude=/shared2 -Sm / | sort -nr | head -10"

sshpass -p 'root-password' ssh -o StrictHostKeyChecking=no  root@localhost " uptime "

No comments: