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
auth:howto:sshkeygitlab [2016/06/07 17:21] apanoauth:howto:sshkeygitlab [2019/12/03 14:18] (current) – [GET/SET SSH KEY] apano
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 key you have to check the file:
  
-To check if you already have an SSH certificate that you have to check the file:  
 LINUX/MACOSX <code>.ssh/id_rsa.pub </code>  LINUX/MACOSX <code>.ssh/id_rsa.pub </code> 
 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 (open the file with a text editor), 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+
  
-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.  +If this file is empty or does not exist, it means that the key was never generated so you have to generate it. 
-To generate the key via command line use the command: +
-<code>ssh-keygen -t rsa -C "your_email@unibz.it"</code> +
-To generate the key via PuTTygen follow the guidelines of the product+
  
-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+To generate an SSH key via command line open a LINUX/MACOSX terminal or WINDOWS Git BASH and run the command: 
 +<code>ssh-keygen -t rsa -C "your@email" -b 4096</code> 
 + 
 + 
 +When you're asked to "Enter a file in which to save the key," select either the default location or a location you prefer and leave as name id_rsa (if this is your only RSA key) or setup a file name of your choice.[[https://docs.gitlab.com/ee/ssh/README.html|GitLab Official Documentation]]   
 + 
 +<note important>Windows Git Bash your rsa-key (~/.ssh/id_rsa) file MUST be called id_rsa.</note> 
 + 
 +You can also use a key generator such as [[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html|PuTTYgen]] instead of using the terminal. Please refer to the guidelines of the product on how to create the RSA key and the location of the file.  
  
 ===== 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 your profile -> Settings -> SSH Keys.
-Once you click Add Key, you will see the key listed in your SSH Keys. +
  
 +{{:auth:howto:gitlab-profile-settings.png?200|}}
  
-===== 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)
-You have to configure your locally installed gitlab to connect using the ssh key+
  
-LINUX/MACOSX Inside terminal, type the following:  +Choose name to identify the key (ex. YourComputerName) 
-git config --global user.name "Firstname Lastname" + 
-git config --global user.email "your_email@unibz.it" +Click Add Key.  
-git config --list+ 
 +The key is listed in your SSH Keys.  
 + 
 +[[https://docs.gitlab.com/ee/gitlab-basics/create-your-ssh-keys.html|Official Gitlab Documentation]] 
 +===== GITLAB CLIENT CONFIGURATION ===== 
 + 
 +==== GLOBAL GIT ACCOUNT ==== 
 +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: 
  
-WINDOWS +<code>
-Inside your GIT bash command line, type the following: +
 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"
 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. 
  
-You have to edit your gitlab configuration to reflect the URL and the username/email to use when connecting. To do so  +This data is saved in the file ~/.gitconfig: 
- +
-1. edit the file ~/.gitconfig and insert your data+
  
 <code txt> <code txt>
 [user] [user]
         name = Lastname Firstname         name = Lastname Firstname
-        email = your_email@unibz.it+        email = your@email
 </code> </code>
  
-2edit .ssh/config +Try to checkout repoShould you experience trouble check the contents of file: .ssh/config. You can manually insert:  
-<code txt>+<code>
 host gitlabhostname.unibz.it host gitlabhostname.unibz.it
-        user your_username 
 </code> </code>
 +
 +
 +        
 +==== LOCAL GIT ACCOUNT ====
 +You can also have different git 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>
 +git config user.name "Firstname Lastname"
 +git config user.email "your_other@email"
 +</code>
 +
  
/data/www/wiki.inf.unibz.it/data/attic/auth/howto/sshkeygitlab.1465312909.txt.gz · Last modified: 2019/01/16 10:03 (external edit)