Skip to content

Instantly share code, notes, and snippets.

@akanehara
Last active September 2, 2015 07:41
Show Gist options
  • Save akanehara/526a4ff0f7cd8b673838 to your computer and use it in GitHub Desktop.
Save akanehara/526a4ff0f7cd8b673838 to your computer and use it in GitHub Desktop.
案件ごとの ssh config 切り替えめんどくさい&ホスト定義名何やったっけ対策
function hss() {
conf="$HOME/.ssh/$1.config" # ~/.ssh/なまえ.config としてconfigを配置しておく
case $# in
1) # configに定義されているホスト一覧
awk '/^Host/{print$2}' $conf | column
;;
2) # ホストに接続
ssh -F $conf $2
;;
*) # つかいかた
echo "Usage: hss <ssh-config-name> [<host>]"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment