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.

Revisions

  1. JoKenPo revised this gist Dec 20, 2024. 1 changed file with 12 additions and 13 deletions.
    25 changes: 12 additions & 13 deletions github+gitlab.MD
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,20 @@
    Usar chaves SSH para múltiplas contas
    ## 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
    Copiar código
    `bash
    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    Salve o arquivo com um nome diferente, como id_rsa_github.
    `
    Slve o arquivo com um nome diferente, como id_rsa_github.

    Adicione a chave ao SSH-Agent:

    bash
    Copiar código
    `bash
    ssh-add ~/.ssh/id_rsa_github
    `
    Configure o arquivo ~/.ssh/config: Adicione entradas separadas para cada conta:

    plaintext
    Copiar código
    `plaintext
    Host gitlab.com
    HostName gitlab.com
    User git
    @@ -26,15 +24,16 @@ 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
    Copiar código
    `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
    Copiar código
    `bash
    ssh -T [email protected]
    `
  2. JoKenPo created this gist Dec 20, 2024.
    40 changes: 40 additions & 0 deletions github+gitlab.MD
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    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
    Copiar código
    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    Salve o arquivo com um nome diferente, como id_rsa_github.

    Adicione a chave ao SSH-Agent:

    bash
    Copiar código
    ssh-add ~/.ssh/id_rsa_github
    Configure o arquivo ~/.ssh/config: Adicione entradas separadas para cada conta:

    plaintext
    Copiar código
    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
    Copiar código
    cat ~/.ssh/id_rsa_github.pub
    Vá para as configurações de SSH no GitHub e cole a chave.

    Teste a conexão:

    bash
    Copiar código
    ssh -T [email protected]