You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This short tutorial shows how to set up multiple different accounts of many git repository sites using SSH, all this tutorial and its commands were aplied in Ubuntu.
### Generate SSH keys
Generate SSH keys for each one of the sites you wanna connect:
1. Open your terminal and type the following command to generate a RSA key:
When prompted for the path of the key, put a specific name to identify the key, for example `id_rsa_gitlab`.
```
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username/.ssh/id_rsa_gitlab
```
After that when asked for password set-up one if you want or press enter to leave it blank.
2. List the new created SSH keys using the following command and validate that the created key is here :
```
ls -al ~/.ssh
```
3. In order to use the generated keys, you’ll need to save them to a configuration file. For OpenSSH clients this is configured in the `~/.ssh/config` file. In this file you can set up configurations for multiple hosts, like GitLab, GitHub, Bitbucket, etc.
If there is not any `config` file create it executing `touch config` and edit it (via nano or any text editor) following the example below.
```
# GitLab.com
Host gitlab.com
Preferredauthentications publickey
IdentityFile ~/.ssh/id_rsa_gitlab
# Github.com
Host github.com
Preferredauthentications publickey
IdentityFile ~/.ssh/id_rsa_github
```
4. Add the SSH keys in the respective sites, for example, for gitlab follow: https://docs.gitlab.com/ee/gitlab-basics/create-your-ssh-keys.html
5. To test the connection (in this case to gitlab) use the following command: