Skip to content

Instantly share code, notes, and snippets.

@hebertviana
Last active October 22, 2025 01:40
Show Gist options
  • Select an option

  • Save hebertviana/fdea9ca7a58fdf60a3db1adbec44fc9e to your computer and use it in GitHub Desktop.

Select an option

Save hebertviana/fdea9ca7a58fdf60a3db1adbec44fc9e to your computer and use it in GitHub Desktop.

🧩 Passo a passo para instalar e configurar o Git + GitHub via SSH no Windows

Este guia ensina do zero como instalar o Git, gerar uma chave SSH e conectar seu PC ao GitHub de forma segura.
Tudo será feito pelo Prompt de Comando (cmd) ou PowerShell.


🪓 1. Instalar o Git

  1. Acesse o site oficial do Git: 👉 https://git-scm.com/downloads

  2. Clique em "Download for Windows".

  3. Execute o instalador (Git-x.x.x.exe).

  4. Durante a instalação:

    • Editor padrão: escolha Visual Studio Code (ou outro, se preferir).
    • PATH environment: marque Git from the command line and also from 3rd-party software.
    • Configurações SSH: deixe como padrão (Use bundled OpenSSH).
    • HTTPS Transport Backend:* Escolha Windows Security Channel
    • Configurações de fim de linha: escolha Checkout Windows-style, commit Unix-style line endings.
    • Terminal: escolha Use Windows' default console window.
    • Git pull: escolha Fast-forward or marge
    • Credential helper: escolhar Gir Credential Manager
    • Extra Options: Maque Enable File System Cache
  5. Após instalar, abra o Prompt de Comando e verifique:

    git --version
    git version 2.51.1.windows.1

🔧 2. Configurar o Git (nome e e-mail)

Essas informações serão usadas nos commits.

git config --global user.name "Seu Nome"
git config --global user.email "seuemail@exemplo.com"

Verifique se foi configurado corretamente:

git config --list

🔐 3. Verificar se há SSH no Windows

Digite no terminal:

ssh

Se aparecer algo como:

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
           [-c cipher_spec] [-D [bind_address:]port] [-E log_file]
           [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
           [-J destination] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-P tag] [-p port] [-Q query_option]
           [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command [argument ...]]

✅ o SSH já está disponível (vem junto com o Git no Windows).

Se aparecer “comando não reconhecido”, reinstale o Git com a opção “Use bundled OpenSSH” marcada.

🧰 4. Gerando uma nova chave SSH

Digite no terminal:

ssh-keygen -t ed25519 -C "seuemail@exemplo.com"

Se o seu sistema não suportar ed25519, use:

ssh-keygen -t rsa -b 4096 -C "seuemail@exemplo.com"

Quando for perguntado:

Enter file in which to save the key (C:\Users\seu-usuario/.ssh/id_ed25519):

Pressione apenas Enter.

Depois:

Enter passphrase (empty for no passphrase):

Você pode deixar em branco (sem senha) ou criar uma senha para mais segurança.

🗝️ 5. Adicionar a chave SSH ao agente (Windows)

No Windows, o comando eval "$(ssh-agent -s)" não funciona.
Use os seguintes comandos dependendo de onde você está rodando:


🟦 Abra um novo terminal utilizando o atalho Git Bash

  1. Inicie o agente SSH:
eval `ssh-agent -s`
Agent pid 1234
  1. Adicione sua chave privada:
ssh-add ~/.ssh/id_ed25519

Se você usou RSA utilize esse comando:

ssh-add ~/.ssh/id_rsa

Será solicitado a senha da sua chave privada se você utilizou passphrase na etapa de geração.

📋 6. Copiar a chave pública

Copie o conteúdo da sua chave:

Ainda no terminal do Git Bash

cat ~/.ssh/id_ed25519.pub

Copie tudo que aparecer (começa com ssh-ed25519 ou ssh-rsa).

🌐 7. Adicionar a chave no GitHub

Acesse https://github.com/settings/keys

  1. Clique em "New SSH key"
  2. Em Title, coloque algo como Meu PC Windows
  3. Em Key type, deixe como Authentication Key
  4. Cole a chave copiada em Key
  5. Clique em Add SSH key

🧪 8. Testar a conexão com o GitHub

No terminal:

ssh -T git@github.com

Vamos reconhecer essa conexão digitando yes

This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Aparecerá algo como:

Hi seu-usuario! You've successfully authenticated, but GitHub does not provide shell access.

✅ Isso significa que sua conexão SSH está funcionando!

📦 9. Clonar um repositório usando SSH

Pegue a URL SSH do seu repositório no GitHub (exemplo):

git@github.com:seu-usuario/seu-repo.git

Clone assim:

git clone git@github.com:seu-usuario/seu-repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment