← すべてのガイド
Git + SSH key authentication setup
Install Git and generate an SSH key pair for authenticating with GitHub/GitLab/Bitbucket without typing a password on every push.
このガイドは上記リンク先にあるGit + SSH key authentication setup公式ドキュメントをもとに作成されています。ディストリビューションやプロジェクトのバージョンは時間とともに変わるため、本番サーバーでこれらのコマンドを実行する前に、必ず公式ドキュメントで正確なパッケージ名・バージョン名を確認してください。
1Install Git
# Windows winget install --id Git.Git -e# MacOS brew install git# Ubuntu/Debian sudo apt install git2Set your name and email
These appear on every commit you make -- use the same email as your GitHub/GitLab account so commits link to your profile.
git config --global user.name "Your Name"git config --global user.email "[email protected]"3Generate an SSH key pair
ssh-keygen -t ed25519 -C "[email protected]"Press Enter to accept the default file location. Ed25519 is the modern, recommended key type -- use `-t rsa -b 4096` only if a specific service requires RSA.
4Add the key to the SSH agent
eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_ed255195Copy the public key and add it to your Git host
Paste the copied key into GitHub/GitLab/Bitbucket's SSH keys settings page, then verify:
# MacOS pbcopy < ~/.ssh/id_ed25519.pub# Windows (PowerShell) Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard# Linux cat ~/.ssh/id_ed25519.pub6Test the connection
ssh -T [email protected]