User Tools

Site Tools


auth_gitlab

Differences

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

Link to this comparison view

Next revision
Previous revision
auth_gitlab [2019/06/21 14:32] – created apanoauth_gitlab [2020/04/02 11:25] (current) – [Check for an existing SSH key] apano
Line 3: Line 3:
 Since July 2016 we use [[https://gitlab.inf.unibz.it/|GitLab]] to collaborate.  Since July 2016 we use [[https://gitlab.inf.unibz.it/|GitLab]] to collaborate. 
  
-UNIBZ users have to login to [[https://gitlab.inf.unibz.it/|GitLab]] and their account will be automatically enabled. +UNIBZ users have to login to [[https://gitlab.inf.unibz.it/|GitLab]] and their account will be automatically enabled a few minutes after they try their first login
  
-External users can sign up with their Google, Twitter, or Facebook account.+External users can sign up with their Google, Github, Twitter, Facebook, Bitbucket or Microsoft account.
  
 Here are some instructions on GitLab to ease its use. Here are some instructions on GitLab to ease its use.
Line 15: Line 15:
  
 You can have different hosts for different Git repositories which you access via specific username/e-mail. You have to configure your local Git with these settings.  You can have different hosts for different Git repositories which you access via specific username/e-mail. You have to configure your local Git with these settings. 
 +
 +You can either clone/push/pull via HTTPS or SSH. If you chose to use HTTPS, you’ll have to enter your credentials every time, if you choose to use SSH you only insert the password of your SSH key. [[https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html#clone-a-repository|Official documentation]]
 +
  
 The steps for pushing and pulling via SSH Key The steps for pushing and pulling via SSH Key
  
-  * Step 1: [[auth:gitlab#identify_or_create_the_ssh_key|Identify or create SSH Key]] - [[https://docs.gitlab.com/ee/ssh/README.html|Official Documentation]]  +  * Step 1: [[auth_gitlab#identify_or_create_the_ssh_key|Identify or create SSH Key]] - [[https://docs.gitlab.com/ee/ssh/README.html|Official Documentation]]  
-  * Step 2: [[auth:gitlab#add_an_ssh_key|Add SSH Key]] - [[https://docs.gitlab.com/ee/gitlab-basics/create-your-ssh-keys.html|Official Documentation]] +  * Step 2: [[auth_gitlab#add_an_ssh_key|Add SSH Key]] - [[https://docs.gitlab.com/ee/gitlab-basics/create-your-ssh-keys.html|Official Documentation]] 
-  * Step 3: [[auth:gitlab#configure_your_local_git_client| Configure your local Git client]]+  * Step 3: [[auth_gitlab#configure_your_local_git_client| Configure your local Git client]]
  
 ===== Identify or create the SSH key ===== ===== Identify or create the SSH key =====
-If you need support on how to generate the SSH key follow our guide on [[auth:howto:sshkeygitlab|How to add an SSH Key for GITLAB]]. + 
 +You need an SSH key that resides on your workstation/notebook. 
 + 
 +==== Check for an existing SSH key ==== 
 + 
 +If you already have an SSH key in your computer you will probably find it here: 
 + 
 +Linux/macOS :      ~/.ssh/id_rsa.pub 
 + 
 +Windows :          %userprofile%\.ssh\id_rsa.pub 
 + 
 + 
 +Open the file with a text editor and check if it has contents. Typically it starts with ssh-rsa or ssh-ed25519. If it has contents [[auth:gitlab#add_an_ssh_key|add it to Gitlab]] if it does not exist or is empty generate an SSH key
 + 
 +==== Generate an SSH key ==== 
 +Open a terminal on Linux or macOS, or Git Bash on Windows and run the command: 
 +<code>ssh-keygen -t rsa -C "your@email" -b 4096</code> 
 +or 
 +<code>ssh-keygen -t ed25519 -C "your@email"</code> 
 + 
 +You can check your e-mail on your [[https://gitlab.inf.unibz.it/profile |Gitlab Profile Settings]] -> Main Settings -> Email 
 + 
 +When you are asked for a location and file name you can either keep the default location or choose a new one. If this is your only key we advice you accept the defaults and maintain the file name id_rsa. Should you have several keys you can name them according to your own preferences. [[https://docs.gitlab.com/ee/ssh/README.html|GitLab Official Documentation]]  
 + 
 +Add the key to your ssh agent by issuing this commands on Linux/macOS or Git Bash for Windows (adapt to your id_rsa path):  
 + 
 +<code> 
 +$ eval "$(ssh-agent -s)" 
 +$ ssh-add -K ~/.ssh/id_rsa 
 +</code> 
 + 
 +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.
  
 ===== Add an SSH key ===== ===== Add an SSH key =====
-If you already have an SSH key login to GitLab and go to → Profile Settings → SSH Keys. In the field Key copy the contents of the file: id_rsa.pub (or any other file containing your key).  +Login to Gitlab and go [[https://gitlab.inf.unibz.it/profile |in Gitlab Profile Settings]] → SSH Keys.  
-Once you click Add Key, you will see the it listed.+ 
 +In the field Key copy the contents of the file: id_rsa.pub (or any other file containing your key).  
 + 
 +Choose a name to identify the key (ex. YourComputerName) and click Add Key, you will see the it listed.
  
 ===== Configure your local Git Client ===== ===== Configure your local Git Client =====
  
 Before proceeding check if your GIT client is already configured.  Before proceeding check if your GIT client is already configured. 
-LINUX/MACOSX terminal or Windows GIT bash , type the following: <code>git config --global --list</code> <code> git config --list </code>+In Linux/macOS terminal or Windows Git Bash, type the following: <code> git config --global --list</code> <code> git config --list </code>
  
-If you use only one server for Git repositories configure it globally, otherwise locally +This command lists any existing GIT repositories configurations.  
- +If you have an already existing configuration choose a local configuration (folder specific) for GIT. If you have no other GIT configurations you can configure it globally. 
-==== Global GIT configuration ==== +==== Global configuration ==== 
-To configure GIT globally using the SSH key Inside the terminal/command line, type:+To configure GIT globally using the SSH key inside the terminal/command line, type:
 <code> <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"
 git config --list git config --list
 </code> </code>
  
-This data is stored in your gitconfiguration file:  +Add your server data in your ssh configuration file. Verify the path is correct
-Linux/Mac: ~/.gitconfig +
-Windows: C:\Users\username\.gitconfig +
- +
-The content should be:  +
-<code txt> +
-[user] +
-        name = Lastname Firstname +
-        email = your_email@unibz.it +
-</code> +
- +
-Add your server data and insert this data in your ssh configuration file. +
  
 Linux/Mac file ~/.ssh/config: Linux/Mac file ~/.ssh/config:
 <code> <code>
 host gitlab.inf.unibz.it host gitlab.inf.unibz.it
 +     HostName gitlab.inf.unibz.it
      user your_username      user your_username
 +     IdentityFile ~/.ssh/id_rsa
 </code> </code>
  
Line 66: Line 94:
 <code> <code>
 Host gitlab.inf.unibz.it Host gitlab.inf.unibz.it
-RSAAuthentication yes +     RSAAuthentication yes 
-IdentityFile ~/.ssh/config/id_rsa.pub+     IdentityFile ~/.ssh/config/id_rsa
 </code> </code>
  
 +The data on the global Git configuration is stored in the file (Linux/macOS) ~/.gitconfig or (Windows) C:\Users\username\.gitconfig
 +
 +The content would be (if configured): 
 +<code txt>
 +[user]
 +        name = Lastname Firstname
 +        email = your@email
 +</code>
 ==== Local Configuration ==== ==== Local Configuration ====
 You have to run the commands inside the directory where you want your repository to be. From terminal/command line, type: You have to run the commands inside the directory where you want your repository to be. From terminal/command line, type:
  
 <code txt> <code txt>
-cd repository_folder+cd repository_folder_in_your_computer
 git config user.name "Firstname Lastname" git config user.name "Firstname Lastname"
-git config user.email "your_other@email"+git config user.email "your@email"
 </code> </code>
  
 Should you receive this message  **fatal: not in a git directory**, you have to initialize the folder as a git folder. Issue command : <code> Should you receive this message  **fatal: not in a git directory**, you have to initialize the folder as a git folder. Issue command : <code>
 git init git init
-</code> and run commands again.  +</code> and run git commands again.  
  
 ===== Basic Git ===== ===== Basic Git =====
/data/www/wiki.inf.unibz.it/data/attic/auth_gitlab.1561120366.txt.gz · Last modified: 2019/06/21 14:32 by apano