1
3

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_configの複数ホストにコマンド同時実行

1
Last updated at Posted at 2017-04-11

Ansibleとかchefでもできますが、軽く設定できてssh_configの設定を使えるといいなと思って書きました。

こんな感じで使えます。

ssh-exec FILTER COMMANDS

ssh-exec ec2_site sudo apt-get update

.bash_rcに追記

ssh-exec () {
    local FILTER=$1
    shift
    local COMMAND=$@
    grep -r "^Host" ~/.ssh/* | awk '{print $2}' | grep $FILTER | xargs -P5 -I% ssh % $COMMAND
}

Bashで動作確認済みです。

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?