Monday, May 11, 2015

Linux - remote ssh and execute commands


The below script will make copy of the file. insert the desired line as the second line.

for LINE in $(cat machines.csv)
do
        ssh root@$LINE "cp /etc/xyz.conf /etc/xyz.conf.old; sed -i '2i nameserver 10.xx.xxx.xxx' /etc/xyz.conf"
done

No comments:

Post a Comment