Skip to content

Quick guide to generating and managing multiple SSH Keys for github and Gitlab.

Notifications You must be signed in to change notification settings

ErnaneJ/Multiplas-SSHKeys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Múltiplas chaves SSH para GitHub e GitLab

1. Gerar Chaves SSH

ssh-keygen -t rsa -C "[email protected]" -b 4096 -f ~/.ssh/id_rsa_github
ssh-keygen -t rsa -C "[email protected]" -b 4096 -f ~/.ssh/id_rsa_gitlab

2. Copiar chaves para GitHub e GitLab

# 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

ssh-add ~/.ssh/id_rsa_github
ssh-add ~/.ssh/id_rsa_gitlab

4. Arquivo de configuração

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

ssh -T [email protected]
yes
# Hi UserName! You've successfully authenticated, but GitHub does not provide shell access.

ssh -T [email protected]
yes
# Welcome to GitLab, @UserName!

About

Quick guide to generating and managing multiple SSH Keys for github and Gitlab.

Topics

Resources

Stars

Watchers

Forks