|
|
|
**Page author:** @tallenet
|
|
|
|
|
|
|
|
# Link SSH key gitlab eclipse
|
|
|
|
|
|
|
|
## Requirement
|
|
|
|
If this is your first time contributing to an Eclipse Foundation project, you'll need to create an account on dev.eclipse.org and sign the Eclipse Contributor Agreement.
|
|
|
|
Refer to [Contributing](Contributing).
|
|
|
|
|
|
|
|
## Procedure
|
|
|
|
In order to push from your devolloping environnement to gitlab eclipse you need to authenticate to your eclipse gitlab account. The fastest and easiest way to do so is by using an SSH key.
|
|
|
|
|
|
|
|
1. Generate a SSH key
|
|
|
|
For example on ubuntu :
|
|
|
|
``` bash
|
|
|
|
cd ~/.ssh
|
|
|
|
ssh-keygen -t rsa -b 4096 -C <prenom.nom@domain.com>
|
|
|
|
```
|
|
|
|
Name it & protect it with a password.
|
|
|
|
For the sake of this tutorial, let's name it "ECLIPSE_RSA".
|
|
|
|
|
|
|
|
2. Link the public SSH key to your eclipse account (https://accounts.eclipse.org/user/login?destination=oauth2/authorize)
|
|
|
|
|
|
|
|
Go to "settings" $\rightarrow$ "SSH Keys"
|
|
|
|
|
|
|
|
Then "Add new key"
|
|
|
|
|
|
|
|
3. Try out the authentication with SSH key
|
|
|
|
|
|
|
|
Add host in the file "~/.ssh/config" :
|
|
|
|
|
|
|
|
```
|
|
|
|
Host eclipse
|
|
|
|
|
|
|
|
Hostname gitlab.eclipse.org
|
|
|
|
|
|
|
|
User git
|
|
|
|
|
|
|
|
PreferredAuthentications publickey
|
|
|
|
|
|
|
|
IdentityFile ~/.ssh/ECLIPSE_RSA
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Try out the authentication with SSH key :
|
|
|
|
``` bash
|
|
|
|
ssh -T gitlab
|
|
|
|
```
|
|
|
|
|
|
|
|
You should get :
|
|
|
|
``` bash
|
|
|
|
Welcome to GitLab, @username !
|
|
|
|
```
|
|
|
|
|
|
|
|
# Git remote with SSH
|
|
|
|
If you are a member of the Aidge gitlab group, you can interact directly with the repository without the Fork and Pull request model.
|
|
|
|
|
|
|
|
## Clone using the SSH key
|
|
|
|
Cloning the git repo using the SSH authentication will automaticaly set the remote address with the ssh authentication.
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
git clone --recursive git@gitlab.eclipse.org:eclipse/aidge/aidge.git
|
|
|
|
```
|
|
|
|
|
|
|
|
However the submodules are cloned with https by default. You need to change the remote manually in each submodule.
|
|
|
|
|
|
|
|
## Switching remote URLs from HTTPS to SSH
|
|
|
|
Inside a git repository :
|
|
|
|
|
|
|
|
1. List your existing remotes in order to get the name of the remote you want to change.
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
$ git remote -v
|
|
|
|
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
|
|
|
|
> origin https://github.com/OWNER/REPOSITORY.git (push)
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Change your remote's URL from HTTPS to SSH with the `git remote set-url` command.
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
git remote set-url origin git@github.com:OWNER/REPOSITORY.git
|
|
|
|
```
|
|
|
|
|
|
|
|
3. Verify that the remote URL has changed.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ git remote -v
|
|
|
|
# Verify new remote URL
|
|
|
|
> origin git@github.com:OWNER/REPOSITORY.git (fetch)
|
|
|
|
> origin git@github.com:OWNER/REPOSITORY.git (push)
|
|
|
|
``` |