User Tools

Site Tools


auth:howto:sshkeygitlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
auth:howto:sshkeygitlab [2016/06/07 17:37] – [LOCAL GITLAB PROFILE] apanoauth:howto:sshkeygitlab [2019/01/16 10:03] – external edit 127.0.0.1
Line 4: Line 4:
 ===== GET/SET SSH KEY ===== ===== GET/SET SSH KEY =====
  
-You need an SSH key that resides on your workstation/notebook. You can use an already existing certificate or generate a new one. +You need an SSH key that resides on your workstation/notebook. You can use an already existing key or generate a new one. 
  
 To check if you already have an SSH certificate that you have to check the file:  To check if you already have an SSH certificate that you have to check the file: 
Line 10: Line 10:
 WINDOWS <code>%userprofile%\.ssh\id_rsa.pub</code> WINDOWS <code>%userprofile%\.ssh\id_rsa.pub</code>
  
-If this file contains an SSH-RSA key, you can proceed to step 2.+If this file contains an SSH-RSA key, proceed to [[https://wiki.inf.unibz.it/auth/howto/sshkeygitlab#configure_gitlab_online| Configure the SSH key on gitlab.inf.unibz.it]].
 If this file is empty or does not exist, it means that the key was never generated.  If this file is empty or does not exist, it means that the key was never generated. 
  
 To generate the key you can use a key generator such as [[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html|PuTTYgen]], or command line.  To generate the key you can use a key generator such as [[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html|PuTTYgen]], or command line. 
 To generate the key via command line use the command: To generate the key via command line use the command:
-<code>ssh-keygen -t rsa -C "your_email@unibz.it"</code>+<code>ssh-keygen -t rsa -C "your_email@unibz.it" -b 4096</code>
 To generate the key via PuTTygen follow the guidelines of the product.  To generate the key via PuTTygen follow the guidelines of the product. 
 +<note important>Windows GitBash your rsa-key (~/.ssh/id_rsa) file must be called id_rsa. Create it if it does not exist and add the generated rsa key there </note>
  
-Remember that you can also use another name for the file name. You can call the file gitlab_rsa if you prefer or anything else. +Remember that you can also use another name for the file name. You can call the file gitlab.inf_rsa if you prefer or anything else.  
 +[[https://docs.gitlab.com/ee/ssh/README.html|GitLab Official Documentation]]
  
 ===== CONFIGURE GITLAB ONLINE ===== ===== CONFIGURE GITLAB ONLINE =====
-Login to GitLab and go to -> Profile Settings -> SSH Keys. In the field Key copy the contents of the file: id_rsa.pub generated in step 1.  +Login to GitLab and go to -> Profile Settings -> SSH Keys.
-Once you click Add Key, you will see the key listed in your SSH Keys. +
  
  
-===== LOCAL GITLAB PROFILE =====+In the field Key copy all the contents of the file: id_rsa.pub (or the specific name of your RSA key)  
 +Click Add Key. 
  
-==== SINGLE GIT ACCOUNT ==== +The key is listed in your SSH Keys
-You have to configure your locally installed gitlab to connect using the ssh key. +
  
-LINUX/MACOSX Inside a terminal, type the following +[[https://docs.gitlab.com/ee/gitlab-basics/create-your-ssh-keys.html|Official Gitlab Documentation]] 
-git config --global user.name "Firstname Lastname" +===== GITLAB CLIENT CONFIGURATION =====
-git config --global user.email "your_email@unibz.it" +
-git config --list+
  
-WINDOWS +==== GLOBAL GIT ACCOUNT ==== 
-Inside your GIT bash command line, type the following: +You have to configure your locally installed gitlab client to connect using the ssh key.  
 + 
 +Inside a terminal (Linux, MacOS)/GIT bash (Windows), type the following:  
 + 
 +<code>
 git config --global user.name "Firstname Lastname" git config --global user.name "Firstname Lastname"
 git config --global user.email "your_email@unibz.it" git config --global user.email "your_email@unibz.it"
 git config --list git config --list
 +</code>
  
 The last command should show the data you entered and is your gitlab global configuration.  The last command should show the data you entered and is your gitlab global configuration. 
Line 52: Line 56:
  
 Try to checkout repo. Should you experience trouble check the contents of file: .ssh/config. You can manually insert:  Try to checkout repo. Should you experience trouble check the contents of file: .ssh/config. You can manually insert: 
 +<code>
 host gitlabhostname.unibz.it host gitlabhostname.unibz.it
 +</code>
  
  
                  
-==== MULTIPLE GIT ACCOUNTS ====+==== LOCAL GIT ACCOUNT ====
 You can also have different gitlab accounts (with different RSA keys) for different hosts. You can keep a global user/email configuration and a local configuration for a specific repository. In the root of a repository, run: You can also have different gitlab accounts (with different RSA keys) for different hosts. You can keep a global user/email configuration and a local configuration for a specific repository. In the root of a repository, run:
  
 <code txt> <code txt>
 git config user.name "Firstname Lastname" git config user.name "Firstname Lastname"
-git config global user.email "your_other@email"+git config user.email "your_other@email"
 </code> </code>
  
  
/data/www/wiki.inf.unibz.it/data/pages/auth/howto/sshkeygitlab.txt · Last modified: 2019/12/03 14:18 by apano