3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

複数リモートサーバにループでsshログインしてコマンドを実行する方法

Last updated at Posted at 2016-05-11

リモートサーバの特定のバージョン確認をしたい場合などに一気に確認でき便利です。

$ for i in $(seq 1 10) ; do ssh 10.3.0.${i} -i id_rsa command /usr/local/nginx/sbin/nginx -v ; done

nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
nginx version: nginx/1.9.14
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?