LoginSignup
0
0

More than 5 years have passed since last update.

.ssh/config から必要な設定だけ表示する zsh 関数

Posted at

とりあえずコードを先に。

.zshrc
# ssh config
function ssh-config {
    sed -n "/$1/,/^$/p" ~/.ssh/config
}

大量の .ssh/config 設定から必要なサーバーのアクセス情報だけ読みたいわけで。

.ssh/config
Host server1
    HostName xxx.xxx.xxx.xxx
    User xxx
    IdentityFile xxxx

Host server2
    HostName xxx.xxx.xxx.xxx
    User xxx
    IdentityFile xxxx

設定は空行で区切っておく。
ホスト名を引数に入れて実行。

$ ssh-config server2

Host server2
    HostName xxx.xxx.xxx.xxx
    User xxx
    IdentityFile xxxx

便利なユーティリティとかないですかね?

0
0
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
0
0