如何将 ssh_config 与用户匹配一起使用

Alv*_*ano 10 linux openssh identity-management private-key

我正在尝试将 ssh_config (客户端)配置为根据同一主机的用户使用不同的密钥文件,但无法使其工作。怎么了?说的是坏参数

Host myServer
    Hostname myServer.net

Match #bad argument at this line
    Host myServer
    User jhon
    IdentityFile ~/.ssh/jhon

Match
    User foo
    IdentityFile ~/.ssh/foo
Run Code Online (Sandbox Code Playgroud)

----------------------->[已解决]<---------------------- -

Host myServer
        Hostname myServer.net

Match user jhon host "myserver.net"
        IdentityFile ~/.ssh/jhon

Match user foo host "myserver.net"
        IdentityFile ~/.ssh/foo


Host another
        User anyOtherOneUser
        Hostname another.net
        # any other configuration

Match user jhon host "another.net"
        IdentityFile ~/.ssh/jhon-another

Match user foo "another.net"
        IdentityFile ~/.ssh/foo-another

Run Code Online (Sandbox Code Playgroud)

小智 6

形成 ssh 手册页:

\n\n
\n

Match\n 限制仅当满足 Match 关键字后面的条件时才使用以下声明(直到下一个 Host 或 Match 关键字)。匹配条件是使用一个或多个条件或始终匹配的单个标记来指定的。可用的条件关键字有:canonical、final、exec、host、originalhost、user 和 localuser。所有标准必须单独出现或紧接在规范或最终标准之后。其他标准可以任意组合。除了所有标准、规范标准和最终标准之外,所有标准都需要论证。可以通过在前面添加感叹号来否定条件 (\xe2\x80\x98!\xe2\x80\x99)。

\n
\n\n

Match您可以使用结束该语句Host。标准不需大写(例如使用host代替Host

\n