Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

.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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away