Site icon EasyOraDBA

Passwordless SSH and Run Commands on Multiple Servers in Linux

— Enable Password-less SSH between Linux Servers Before using PSSH —
In the Server (192.168.100.55) from where you want to connect to the other nodes
— First do for that server itself so you can query that server also from PSSH–

ssh-keygen -t rsa
ssh root@192.168.100.55 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.55 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.55 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.55
ssh root@192.168.100.57 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.57 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.57 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.57
ssh root@192.168.100.58 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.58 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.58 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.58
ssh root@192.168.100.59 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.59 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.59 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.59
ssh root@192.168.100.60 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.60 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.60 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.60
ssh root@192.168.100.61 mkdir -p .ssh
cat .ssh/id_rsa.pub | ssh root@192.168.100.61 'cat >> .ssh/authorized_keys'
ssh root@192.168.100.61 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
ssh root@192.168.100.61

— Download RPM of PSSH from
http://rpm.pbone.net/index.php3/stat/4/idpl/17671484/dir/redhat_el_6/com/pssh-2.3-1.el6.rf.noarch.rpm.html

rpm -ivh pssh-2.3-1.el6.rf.noarch.rpm

— Create a file called pssh-hosts and enter the host ip’s —

192.168.100.55
192.168.100.57
192.168.100.58
192.168.100.59
192.168.100.60
192.168.100.61

— To Check pssh —

pssh -h /root/pssh-hosts -l root -i "uptime"

— To Copy Files using PSCP–

pscp -h /root/pssh-hosts -l root -v /home/oracle/app/oracle/product/12.1.0/client_1/network/admin/tnsnames.ora /home/oracle/app/oracle/product/12.1.0/client_1/network/admin/

 

Exit mobile version