SSH alias/config not working in build on agent
Hi,
I just spent some time trying to understand why my build did not resolve SSH aliases in ~/.ssh/config, and I would like to share the solution in case someone as the same issue.
TL;DR: the authentication in the VCS root was set to “Uploaded key”, this is the value set by the build configuration creation wizard. When I set it to “Default private key”, the alias worked.
The support helped me to understand why:
This behavior is expected and comes from the difference between the two SSH authentication modes in TeamCity.
When “Default private key” is selected, TeamCity uses the system SSH client on the agent and follows standard SSH behavior. This includes reading /.ssh/config, so SSH aliases (like sshalias) work as expected.
When “Uploaded key” is selected, TeamCity runs SSH using an internal helper with the uploaded key and does not read or honor ~/.ssh/config. As a result, host aliases cannot be resolved and SSH tries to treat sshalias as a real hostname, leading to the UnknownHostException.
This is why the alias works with Default private key but fails with Uploaded key.
If you rely on SSH aliases or custom host mappings, Default private key is the recommended option.
Please sign in to leave a comment.