Skip to content

Instantly share code, notes, and snippets.

@JoKenPo
Last active December 20, 2024 00:13
Show Gist options
  • Save JoKenPo/40b49c94da7234238e2c84ed70f8b8cf to your computer and use it in GitHub Desktop.
Save JoKenPo/40b49c94da7234238e2c84ed70f8b8cf to your computer and use it in GitHub Desktop.
Como usar uma conta/email para o Gitlab e outra para o Github

Usar chaves SSH para múltiplas contas

Se você está usando SSH para autenticação, pode configurar chaves separadas para GitLab e GitHub.

Crie uma nova chave SSH para cada conta:

bash ssh-keygen -t rsa -b 4096 -C "[email protected]" Slve o arquivo com um nome diferente, como id_rsa_github.

Adicione a chave ao SSH-Agent: bash ssh-add ~/.ssh/id_rsa_github Configure o arquivo ~/.ssh/config: Adicione entradas separadas para cada conta:

`plaintext Host gitlab.com HostName gitlab.com User git IdentityFile ~/.ssh/id_rsa_gitlab

Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa_github ` Adicione a chave SSH na sua conta do GitHub: Copie a chave pública gerada:

bash cat ~/.ssh/id_rsa_github.pub Vá para as configurações de SSH no GitHub e cole a chave.

Teste a conexão:

bash ssh -T [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment