
上QQ阅读APP看书,第一时间看更新
Configuring SSH keys
To configure and set up SSH keys for your GitHub account, follow these steps:
- Check whether you already have an ssh key pair.
- Open Git Bash and enter ls -al ~/.ssh to see whether existing SSH keys are present:
$ ls -al ~/.ssh

- The public key consists of the .pub extension. Create a new key pair (skip this step if you already have a key pair).
- Open Git Bash and paste in the following text, substituting your GitHub email address for the one shown:
$ ssh-keygen -t rsa -b 4096 -C your_email@example.com

- When you're prompted to Enter a file in which to save the key, press the Enter button to accept the default file location mentioned:

- When prompted, type a secure passphrase (recommended), or press Enter to continue without a passphrase:

- The entire setup will look as shown in the following screenshot:

- Add the newly created SSH keys into ssh-agent; for that, ensure ssh-agent is running:
$ eval $(ssh-agent -s)

- Add the newly created private key to ssh-agent.
- If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file:

- To add SSH keys to your GitHub account, download/copy the public key from ~/.ssh/id_rsa.pub.
You can also copy the public key manually, or you can use the following tools:
Windows:
$ clip < ~/.ssh/id_rsa.pub
Linux:
$ sudo apt-get install xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub
Mac:
$ pbcopy < ~/.ssh/id_rsa.pub
Windows:
$ clip < ~/.ssh/id_rsa.pub
Linux:
$ sudo apt-get install xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub
Mac:
$ pbcopy < ~/.ssh/id_rsa.pub
- In the upper-right corner of the GitHub page, click your profile photo, and then click Settings:

- In the Personal settings sidebar, click on SSH and GPG keys, and then select New SSH key:

- Give a meaningful name to your key in the Title field and paste your key into the Key field. Click on Add SSH key:

- When prompted, type your GitHub password.
- The newly added SSH keys will look like this:

Great, so now you have successfully added SSH keys to your GitHub account!