Skip to content
Tsuyoshi Tokuda edited this page Mar 25, 2023 · 6 revisions

Git configuration

How to create a SSH key to communicate with GitHub

Since August 13, 2021, GitHub no longer accepts password authentication for command-line access. And we need to authenticate via a personal access token or use an SSH key.

References:

Step 1: Generate a SSH key

Create a new SSH key pair by running the following command:

❯ ssh-keygen -t ed25519 -C "[email protected]"

Note that specifying a reliable ED25519 algorithm to create the SSH key.

I use a noreply email address to hide my personal email address.
We can get it from the GitHub's Emails setting page.

And since I use the GPG key to sign my git commits, I use the noreply email address to sign them.

Step 2: Copy public key

In the Step 1, A public key and a private key are created. You can see the created key pairs in ~/.ssh directory.

❯ pbcopy < ~/.ssh/CREATED_SSH_KEY.pub

Step 3: Register public key to GitHub

And last, register the public key copied in Step 2 to GitHub. For details, see Adding a new SSH key to your GitHub account.

Step 4: Using the keychain to authenticate on Mac

To register a private key with ssh-agent, run the following command:

❯ ssh-add --apple-use-keychain ~/.ssh/CREATED_SSH_KEY

Step 5: Testing SSH connection

❯ ssh -T [email protected]
Hi tokuda109! You've successfully authenticated, but GitHub does not provide shell access.

Git tools

tig

lazygit