Last active
September 2, 2015 07:41
-
-
Save akanehara/526a4ff0f7cd8b673838 to your computer and use it in GitHub Desktop.
案件ごとの ssh config 切り替えめんどくさい&ホスト定義名何やったっけ対策
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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