Ali
Ali

Reputation: 1631

Bash script to pull pending Linux security updates from remote servers

I'm trying to pull pending linux updates from remote servers and plug them into Nagios. Here's a stripped down version of the code - the code that's giving me an error:

UPDATES=$(sshpass -p "password" StrictHostKeyChecking=no user@server:/usr/lib/update-notifier/apt-check 2>&1)

echo $UPDATES

Error message:

sshpass: Failed to run command: No such file or directory

Upvotes: 0

Views: 384

Answers (1)

iamauser
iamauser

Reputation: 11479

Command in the question is wrong in multiple ways.

sshpass -p"password" \
ssh -o StrictHostKeyChecking=no user@server "/usr/lib/update-notifier/apt-check" 2>&1

For the -p option, there shouldn't be any space between the option and the value.

sshpass needs a command as argument, which is ssh in this case.

StrictHostKeyChecking=no should be following the option -o for ssh.

A space, not a : is needed between user@server and the command you are going to run remotely, i.e., /usr/lib/....

Upvotes: 1

Related Questions