0

I am writing a Nagios plugin that will check disk space on a given IP (that would be a $HOSTADDRESS$ in plugin). The script is perfectly working but I need to enter a password every time I ssh. I think this is not acceptable in terms of plugin. I wonder, therefore, if there is a way to place a password into a command so plugin will take it automatically?

#!/bin/bash

used_space=$(ssh $1 "df -h /" | grep -v Filesystem | awk '{print $5}' | sed 
's/%//g');

case $used_space in
   // here goes OK,WARNING,CRITICAL etc. code
esac
2
  1. You can configure ssh-keygen where your plugin can login to the remote server automatically without a password

  2. by sshpass in which we can pass the password in the command line itself

    sshpass -p "password" ssh hostname "df -Ph  | sed -n '/\/$/p'| sed "s/%//g""|awk '{print $(NF-1)}'
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.