https://github.com/ernanej/multiplas-sshkeys
Quick guide to generating and managing multiple SSH Keys for github and Gitlab.
https://github.com/ernanej/multiplas-sshkeys
github-config gitlab ssh-git ssh-key
Last synced: over 1 year ago
JSON representation
Quick guide to generating and managing multiple SSH Keys for github and Gitlab.
- Host: GitHub
- URL: https://github.com/ernanej/multiplas-sshkeys
- Owner: ErnaneJ
- Created: 2021-05-28T13:30:57.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-12T14:59:12.000Z (almost 5 years ago)
- Last Synced: 2025-02-05T18:59:29.448Z (over 1 year ago)
- Topics: github-config, gitlab, ssh-git, ssh-key
- Homepage:
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Múltiplas chaves SSH para GitHub e GitLab
## 1. Gerar Chaves SSH
``` bash
ssh-keygen -t rsa -C "user@email.com" -b 4096 -f ~/.ssh/id_rsa_github
ssh-keygen -t rsa -C "user@email.com" -b 4096 -f ~/.ssh/id_rsa_gitlab
```
## 2. Copiar chaves para GitHub e GitLab
``` bash
# Copiar chave pública para o GitHub
cat < ~/.ssh/id_rsa_github.pub
# Em seguida colar no painel do GitHub
# Copiar chave pública para o GitLab
cat < ~/.ssh/id_rsa_gitlab.pub
# Em seguida colar no painel do GitLab
```
## 3. Adicionar as chaves ao SSH-Agent
``` bash
ssh-add ~/.ssh/id_rsa_github
ssh-add ~/.ssh/id_rsa_gitlab
```
## 4. Arquivo de configuração
``` bash
touch ~/.ssh/config
nano ~/.ssh/config
```
**Arquivo** `config`
```
# Conta do GitHub
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
# Conta do GitLab
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitlab
```
## 5. Testando as conexões
``` bash
ssh -T git@github.com
yes
# Hi UserName! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T git@gitlab.com
yes
# Welcome to GitLab, @UserName!
```