mkdir -p ~/.ssh
chmod 700 ~/.ssh
/usr/bin/ssh-keygen -t rsa
然後再需要批量分發的主機上
touch ~/.ssh/authorized_keys
ssh 192.168.1.20 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
說明:192.168.1.20是分發主機的IP地址
The authenticity of host 'Linux1 (192.168.1.100)' can't be established.
RSA key fingerprint is 2f:cc:a1:4f:2b:67:01:6a:d1:9e:0b:ab:c8:9e:57:a1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'Linux1,192.168.1.100' (RSA) to the list of known hosts.
Oracle@Linux1's passWord: xxxxx
在需要分發的主機執行
chmod 600 ~/.ssh/authorized_keys
在分發主機驗證
ssh 192.168.1.19 hostname
RS9
在分發主機上常見 scp.sh 文件
從分發主機192.168.1.20向 192.168.1.19、192.168.1.10 分發文件
scp -r /usr/local/adsit/webaPPS/preroll/WEB-INF/classes [email protected]:/home/adsit/
scp -r /usr/local/adsit/webaPPS/preroll/WEB-INF/classes [email protected]:/home/adsit/
在分發主機執行 scp.sh 實現拷貝功能。