我想要实现的是重新启动多个远程服务器,而无需单独登录。 所以我解雇了以下内容,希望它会跳到服务器93,95和97并重启每个。
[root@<home_server> ~]# seq 93 2 97 |xargs -I{} ssh <remoteservernumber_>{} "hostname; reboot"
The authenticity of host '<remoteservernumber_93 (IP.IP.IP.IP)' can't be established.
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remoteservernumber_93 (IP.IP.IP.IP)' (RSA) to the list of known hosts.
root@remoteservernumber_93's password:
remoteservernumber_93
Connection to remoteservernumber_93 closed by remote host.
xargs: ssh: exited with status 255; aborting
但是,我最终得到的是当第一台服务器重新启动时它会终止连接并且它不会跳到下一台服务器上。我做错了什么?
答案 0 :(得分:1)
由于缺少更好的替代方案,我发现以下脚本有效:
for i in <server-1> <server-2> ... <server-n> ; do ssh $i "hostname; sudo reboot"; done