如何在 Windows 和 macOS 上建立 SSH 金鑰並新增至 GitHub | How to Create SSH Key and Add to GitHub on Windows and macOS
Published in
3 min readJul 27, 2024
Here are steps for creating an SSH key and adding it to GitHub, tailored for both Windows and macOS:
On Windows
- Open Git Bash:
- Open the Git Bash application.
2. Generate a new SSH key:
- Run the following command, replacing
your_email@example.com
with your GitHub email address:
ssh-keygen -t ed25519 -C "your_email@example.com"
- If your system does not support Ed25519, use:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
3. Follow the prompts:
- Accept the default file location by pressing Enter.
- Optionally, enter a passphrase for additional security.
4. Start the SSH agent:
- Run the following command:
eval "$(ssh-agent -s)"
5. Add your SSH key to the ssh-agent:
- Run the following command, adjusting the path if you used a different file name:
ssh-add ~/.ssh/id_ed25519