How to Add SSH Public Keys on GitHub

Revision as of 13:30, 22 March 2023 by Lukegao1 (talk | contribs) (创建页面,内容为“Adding SSH public keys to your GitHub account is an important step if you want to authenticate with GitHub via SSH. This allows you to securely interact with GitHub without having to enter your username and password every time. Here are the steps to add SSH public keys to your GitHub account: Step 1: Generate SSH key pair First, you need to generate a new SSH key pair on your local machine. You can do this by running the following command in your terminal: ``…”)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adding SSH public keys to your GitHub account is an important step if you want to authenticate with GitHub via SSH. This allows you to securely interact with GitHub without having to enter your username and password every time. Here are the steps to add SSH public keys to your GitHub account:

Step 1: Generate SSH key pair First, you need to generate a new SSH key pair on your local machine. You can do this by running the following command in your terminal:

``` ssh-keygen -t rsa -b 4096 -C "[email protected]" ```

This will generate a new SSH key pair using RSA encryption with a key size of 4096 bits. You can specify a different email address if you prefer.

Step 2: Add public key to GitHub Once you have generated your SSH key pair, you need to add the public key to your GitHub account. To do this, follow these steps:

1. Log in to your GitHub account and click on your profile picture in the top-right corner of the screen. 2. Click on "Settings" from the drop-down menu. 3. On the left-hand side of the screen, click on "SSH and GPG keys". 4. Click on "New SSH key". 5. Enter a title for your SSH key (e.g. "My laptop"). 6. Copy the contents of your public key file (usually `~/.ssh/id_rsa.pub`) and paste it into the "Key" field. 7. Click on "Add SSH key".

Step 3: Test your SSH connection To make sure that your SSH connection is working correctly, you can try to connect to GitHub using SSH. To do this, run the following command in your terminal:

``` ssh -T [email protected] ```

If everything is working correctly, you should see a message that says "Hi username! You've successfully authenticated, but GitHub does not provide shell access." where "username" is your GitHub username.

That's it! You have now added your SSH public key to your GitHub account and can use SSH to interact with GitHub securely.