I'm trying to configure my ssh_config (CLIENT) to use different keyfiles depending on the user for the same host, but unable to make it work. What is wrong? It says bad arument
Host myServer Hostname myServer.net
Match #bad argument at this line Host myServer User jhon IdentityFile ~/.ssh/jhon
Match User foo IdentityFile ~/.ssh/foo----------------------->[SOLVED]<-----------------------
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 1 1 Answer
Form the ssh man Page:
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, final, exec, host, originalhost, user, and localuser. The all criteria must appear alone or immediately after canonical or final. Other criteria may be combined arbitrarily. All criteria but all, canonical, and final require an argument. Criteria may be negated by prepending an exclamation mark (‘!’).
You end the Match statement by using Host. Criterias are uncapitalised (e.g. use host instead of Host)