IT:AD:SSH:HowTo:Configure the association between Host and Key
- See also:
- IT:AD:SSH-KEYGEN ← use to create new key pairs
- IT:AD:SSH-ADD ← use to register new key pairs
</div>
## Summary ##
It's useful to associate to each target, which key to use.
ie, on BitBucket use the id_* key, on Git, another, etc.
Nice thing about most linux apps is that they have a config file in your %userprofile% folder. Same for SSH/.
## Process ##
- So if it doesn't already exist, create the ssh config file first:
~/.ssh/config - Edit it with a text editor
- Add (note the second line is indented by a single space):
Host bitbucket.org StrictHostKeyChecking no UserKnownHostsFile=/dev/null IdentityFile ~/.ssh/id_rsa
After editing the file, restart the CLI (Git Bash/ or other) for the new settings to take effect so that you can test the connection:
### The %HOME% variable – for Git and SSH ###
Git is going to use SSH automatically. In theory this means that IT:AD:Git uses IT:AD:SSH, which uses the above config file.
In theory…
The problem is that when IT:AD:Git is looking for %HOME% which is the Linux environment variable that is equivalent to ~/ which is the equivalent to the Windows %userprofile% variable. And since it's not set, it won't find it, therefore won't find the %userprofile%\.ssh\config file.
Ensure you've followed the instructions here: IT:AD:Git:HowTo:Install
### Which Account?
The above solves it for the command line scenario.
But when running within a CI environment, such as IT:AD:Jenkins, the service account (or apphost account in other scenarios) is probably not the same user.
So you have to
- RDP in as the service account
- set the
%HOME%account from the service account in question. - for that account, create the .ssh folder with a set of keys in it
- <div tip“
>If the service account is the `Local System` account, then the `%HOME%` directory is `C:\Windows\SysWOW64\config\systemprofile\.ssh`</callout>
## Resources ##