私の現在の.ssh / configファイルの設定は次のとおりです。
Host *
FingerprintHash sha256
StrictHostKeyChecking yes
PasswordAuthentication no
GSSApiAuthentication no
KbdInteractiveAuthentication no
CheckHostIP yes
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
Port 28282
1つのホストIP(1.2.3.4)にのみ適用される別のルールを追加したいと思います。
だから私は.ssh / configファイルに次のルールを追加しました。
Host 1.2.3.4
Hostname 1.2.3.4
Port 22
ただし、最初のより広い規則は規則1.2.3.4に影響を与え続けます。
デフォルト設定(パスワードでログインなど)を使用して1.2.3.4にSSH経由で接続したい(*ルールの影響を受けません)。
実行すると、次のようなメッセージが表示されます(ルールが適用されているようです)。ポート28282経由で試してください。ssh -v [email protected]
debug1: /home/ryan/.ssh/config line 23: Applying options for *
debug1: /home/ryan/.ssh/config line 74: Applying options for 1.2.3.4
..
debug1: Connecting to 1.2.3.4 [1.2.3.4] port 28282.
debug1: connect to address 1.2.3.4 port 28282: Connection refused
パスワードでログインしてポート22を1.2.3.4に変更するには、何を変更する必要がありますか?
よろしくお願いします。
ベストアンサー1
グループの順序が間違っているようです。ドキュメントにはまったく明確ではありません(man ssh_config
しかし」各パラメータに対して最初に取得された値が使用されます。したがって、設定ファイルでより一般的な一致を追加する必要があります。
次の順序で配置してください。
Host 1.2.3.4
Port 22
Host *
FingerprintHash sha256
StrictHostKeyChecking yes
PasswordAuthentication no
GSSApiAuthentication no
KbdInteractiveAuthentication no
CheckHostIP yes
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
Port 28282
または、Host *
設定をブロック外に移動してグローバルにします。その後、これをHost 1.2.3.4
ブロックで上書きできます。
ただし、名前またはパターンに基づいて特殊なケースのホストセットを列挙する方が合理的です。これにより、ポート 22 を使用する基本操作がすべてのシステムに適用され続けます。