Shell Script To Update Remote RHEL and CentOS Servers Over SSH Session

in Categories Automation & Management last updated January 8, 2010
# A simply shell script to update all remote Redhat Enterprise Linux 5 / CentOS Linux 5 servers
# You must have ssh public and private key installed. This will save a lot of time if you
# have 5-7 servers. The last example shows how to login as a normal user and run sudo 
# to update the same.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
# an array to store all ssh commands
	"ssh -p222 yum update -y"
	"ssh -p333 yum update -y"
	"ssh yum update -y"
	"ssh user1@ -t sudo  '/usr/bin/yum update -y' "
# simply run array item
for c in "${hosts[@]}"

See how to install ssh-keys .

Share this on:

2 comment

Leave a Comment