Bypass passphrase when cloning git repositories
When you clone a repository using a SSH key, it prompts you to enter the passphrase. If you’re cloning a single repository, this may not be an issue. However, if you’re trying to clone multiple repositories, this becomes a troublesome. We can bypass this via configuring SSH auth.
First create a config file in ~/.ssh directory.
mkdir ~/.ssh
touch ~/.ssh/config
vim ~/.ssh/config
Use the SSH currently used in GitHub and register in like the following:
Host github.com
HostName github.com
IdentitiesOnly yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
In the case of macOS, add the SSH key to the system keychain as well.
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Add GitHub’s server host key to the known_hosts.
ssh-keyscan github.com >> ~/.ssh/known_hosts
Confirm SSH key auth is working properly.
ssh -T git@github.com
Setting is complete if you see a message like the below:
Hi tadanoyu! You've successfully authenticated,
but GitHub does not provide shell access.
Once the setup is complete, it won’t ask for the passphrase when you clone a repository using SSH key.