Setting Up SSH Authentication for Git and Mercurial
SSH Authentication is supported only if codeBeamer is running on Linux/Unix server.
If port redirection is used for codebeamer, please check the value of CB_BASE_URL in scmloop/scm-ssh script.
Generating SSH keys
A keypair is only valid if it is a pair: your local operating system user needs access to both (in Unix/Linux enviroment: ~/.ssh directory). If you login to another local user, you must either:
AllowUsers must contain all operating system accounts allowed to login via SSH.
You can now generate your keys for your operating system user and associate them with your codeBeamer account.
Linux and Mac OS X
- Open a terminal window on your desktop machine
- Type the following commands: use your own user ID and accept the default options.
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zk/.ssh/id_rsa):
Created directory '/home/zk/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/zk/.ssh/id_rsa.
Your public key has been saved in /home/zk/.ssh/id_rsa.pub.
The key fingerprint is:
0f:a9:76:db:20:f9:cc:25:42:cc:65:7e:ce:ac:97:03 zk@zk-ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| o |
| o * |
| S . |
| EB o |
| =.B.+ |
| . B+* . |
| ..=.. |
+-----------------+
Finally run the following command:
cat $HOME/.ssh/id_rsa.pub
and copy the output. This is your public key.
Windows
On Windows, Git (http://msysgit.github.io/) comes with a tool called Git Bash. You can access this trhough Start > Programs > Git. Using this tool you can generate the keys following the same steps as for Linux.
On Windows SSH keys can be generated using PuTTYGen (the download link can be found on the PuTTY Download Page. If you're using Mercurial also download ptlink from this page.
Start PuTTYGen, generate the key (Generate button) and save the private key to a file (Save private key button) like 'key.ppk' under your home directory. Copy the content of Public key for pasting into OpenSSH authorized_keys file textbox (this is your public key).
Figure: Generate SSH Key with PuttyGen
You must login to see this link. Register now, if you have no user account yet.
For Mercurial you have to edit the .hgrc file in your home directory. Add the following lines (if the file doesn't exist just create it):
[ui]
ssh = "C:\Program Files\PuTTY\ptlink.exe" -i "USERHOME\key.ppk"
Note that the path of ptlink can be different on your environment. Substitute USERHOME with your home directory.
Before first accessing codeBeamer through ssh run the following command:
"C:\Program Files\PuTTY\ptlink.exe" ssh://CODEBEAMER_URL
This will add the host key of codeBeamer to the known hosts.
Associating Your SSH key with Your codeBeamer Account
You can associate your generated public key with your codeBeamer account using the following steps:
- Return to your codeBeamer window
- Log in again or just select the My Start tab
- Now select the Account Info tab
- Select the Edit Public SSH Keys link
- Upload or copy-paste the public key from the terminal (linux) or from PuTTYGen (Windows) into the boxes and save it.
- Save
Setting up a custom private-key
If you want to use the custom private-key - something other than .ssh/id_rsa- and you want to use this with codeBeamer and your git cloning or authentication fails then you may have to set-up git to use this custom private key. There are several ways to do this, see How to tell git which private key to use.
This video also illustrates how to do this: How To Custom SSH key video