Generating a new SSH key and adding it to the ssh-agent
Generating a new SSH key
Chạy lệnh bên dưới (có thể không cần nhập pass phase – nhập enter để tiếp tục)
bd@devk2x % ssh-keygen -t rsa -b 4096 -C "email@example.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/bd/.ssh/id_rsa): /Users/bd/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/bd/.ssh/id_rsa. Your public key has been saved in /Users/bd/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Imkg4JVUlE4ErSHIg15TNWrCIoEsQCqx2KTB1RysOw4 firstname.lastname@example.org The key's randomart image is: +---[RSA 4096]----+ |/.+=%*+o | |X#o= B. . | |@o*oBo | |oo.+oo | | = . S | | E + . . | | o . | | . | | | +----[SHA256]-----+
Adding your SSH key to the ssh-agent
Start the ssh-agent in the background.
bd@devk2x % eval "$(ssh-agent -s)" Agent pid 4684
Add the SSH key to your account on GitHub
Copy the SSH public key to your clipboard.
bd@devk2x % pbcopy < ~/.ssh/id_rsa.pub
In the upper-right corner of any page, click your profile photo, then click Settings.
In the user settings sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
Paste your key into the “Key” field.
Click Add SSH key.
Test connection to github
bd@devk2x % ssh -T email@example.com Hi devk2x! You've successfully authenticated, but GitHub does not provide shell access.