Ohjeah!

vSphere advanced upgrades %53 off!

Archive for the ‘ssh’ tag

Remote Server Shutdown

without comments

One of my recent projects was to initiate a server-wide shutdown should our UPS ever run low.  I currently have Zenoss monitoring the health status of the UPS, including the remaining charge on the battery.  Using Zenoss thresholds, I can make a script execute if the battery ever runs low.

Our Zenoss deployment currently runs on CentOS, so I put down a method to shut down each type of host from a linux platform.  After much researching and testing, this is what I came up with (and am currently using in my shutdown script).

For Windows:

net rpc SHUTDOWN -C "Automated shutdown" -f -I "$server" -W $domain -U $username%$password

I replaced my arguments with some that would be more readable.  User and password are separated with %.

For Linux:

CMD="ssh -l $username $server shutdown -h now"
              expect -c "
              match_max 100000
              spawn $CMD
 
              expect {
                \"Are you sure you want to continue connecting (yes/no)?\" {
                send \"yes\r\"
                exp_continue
                }
                \"password:\" {
                send \"$password\r\"
                expect -re \"$username*\"
                }
              }
              "

I wanted to shutdown linux servers without using keys but had to overcome the “do you want to connect” prompt.  In order to do that I had to use exact which can be installed with “yum install exact”

By turning these into functions and passing arguments, you can make a shutdown script in a couple of minutes.

Written by jro

March 3rd, 2009 at 12:34 pm

Posted in Computers

Tagged with , , ,

Linux SSH + PAM + LDAP + 2003 R2 AD Deployment

without comments

Often I find my self working in a department where the skill sets of individuals varies significantly, and my current position is no different.  While there is nothing wrong with this, there have been several occasions (like being on vacation), where help desk personnel or other less savvy users are called upon to perform basic functions .  Read the rest of this entry »

Written by jro

September 23rd, 2008 at 9:47 am

Posted in Computers

Tagged with , , , , ,