Tell SSH to to use special IdentityFile for special user

202 views Asked by At

I need to tell SSH to use special IdentityFile for special user.

For example host specs [email protected] [email protected] should use key ~/.ssh/id_wizard

I'd like to write

User wizard
  IdentityFile ~/.ssh/id_wizard

but there is no such option in man ssh_config.

1

There are 1 answers

0
Kenster On BEST ANSWER

You should be able to use the Match directive. Match is a more generalized form of the Host directive:

Match
Restricts the following declarations (up to the next Host or Match keyword) to be used only when the conditions following the Match keyword are satisfied. Match conditions are specified using one or more criteria or the single token all which always matches. The available criteria keywords are: canonical, exec, host, originalhost, user, and localuser. The all criteria must appear alone or immediately after canonical. Other criteria may be combined arbitrarily. All criteria but all and canonical require an argument. Criteria may be negated by prepending an exclamation mark (‘!’).
...
The other keywords' criteria must be single entries or comma-separated lists and may use the wildcard and negation operators described in the PATTERNS section. ... The user keyword matches against the target username on the remote host.

So:

Match user wizard
    IdentityFile ~/.ssh/id_wizard