SSH Agent
The SSH Agent build feature, available since TeamCity 9.1, runs an SSH agent with the selected uploaded SSH key during a build. When your build script runs an SSH client, it uses the SSH agent with the loaded key.
Setup Notes
TeamCity SSH Agent uses a native ssh agent from the OpenSSH included with Linux and Mac OS X, so the feature works out of the box for these OS's. For Windows, OpenSSH needs to be installed (e.g. as a part of CygWin, MinGW or a part of Git distribution for Windows).
The SSH agent must be added to $PATH on Unix-like OS's and to %PATH% on Windows.
For each TeamCity build agent a separate ssh agent is started,so it is possible to use this feature if several build agents are installed on the same machine.
Disabling SSH host key checking
The first time you connect to a remote host, the SSH client asks if you want to add a remote host's fingerprint to the known hosts database at ~/.ssh/known_hosts
.
To avoid such prompts during a build, you need to configure the known hosts database beforehand. If you trust the hosts you are connecting to, you can disable known hosts checks:
either for all connections by adding something like this in
~/.ssh/config
:Host * StrictHostKeyChecking noor for an individual command by running an ssh client with the
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
options.
See more information in the man pages for ssh, ssh-agent and ssh-add commands.