Github SSH key is created in configuration (Windows)

Source: Internet
Author: User
Tags github ssh key

The recent configuration of the GitHub SSH key, the search for a large amount of data found GitHub official has a related tutorial ... Translate the official tutorials here to deepen your impressions

Original link: https://help.github.com/categories/ssh/


Generating an SSH key (generated ssh keys) is a way to identify trusted computers. You can generate an SSH key and add the public key to your account GitHub as described in this section.

Checking for existing SSH keys (check for SSH key already exists)
Before you generate an SSH key, you can check to see if you already have SSH key:
    1. Open git Bash
    2. Input
      Ls-al ~/.ssh
      To see if there is an SSH key present
    3. Check the/.ssh directory to see if there is a public SSH key
In general, the file name of the public SSH key is the following:
    • Id_dsa.pub
    • Id_ecdsa.pub
    • Id_ed25519.pub
    • Id_rsa.pub

Generating a new SSH key and adding it to the ssh-agent (generate a newer SSH key and add to Ssh-agent)
After you have checked the existing SSH key, you can create a new SSH key:
    1. Open git Bash
    2. Enter this string:
      Ssh-keygen-t rsa-b 4096-c "[Email protected]"
      Generate a new SSH key, use the filled-in email address as the label for the SSH key, and generate the RSA key pair
    3. When you see the following prompt:
      Enter a file in which to save the key (/USERS/YOU/.SSH/ID_RSA): [Press ENTER]
      Press ENTER to place the SSH key in the default address
    4. Then set the password for SSH key:
      Enter passphrase (empty for no passphrase): [Type a passphrase]enter same passphrase again: [Type passphrase again]

After you create the SSH key, you need to add it to the ssh-agent:
    1. First, ensure that the ssh-agent is enabled:
      Eval "$ (ssh-agent-s)"
      The instruction returns the process ID to indicate that the ssh-agent has been enabled
    2. Use the following command to add SSH key to the ssh-agent:
      Ssh-add ~/.ssh/id_rsa

Adding a new SSH key to your GitHub account (add SSH key for your GitHub accounts)
After adding SSH key to ssh-agent, you need to add SSH key to your GitHub account:
    1. Open git Bash and use the instructions to copy SSH key to the clipboard:
      Clip < ~/.ssh/id_rsa.pub
      If you do not succeed, open the file with the editor and copy the contents directly
    2. In the upper right corner of GitHub, click setting:

    3. On the left, choose SSH and GPG keys:

    4. Click New SSH key:

    5. Fill in the appropriate title for your SSH key at the title and paste the SSH key you copied at key

    6. Click Add SSH key:

    7. Enter your GitHub account password to confirm this operation

Testing your SSH connection (test your SSH connection)
After doing a series of actions above, it's time to see if your SSH connection was successful:
    1. Open git Bash
    2. Enter the following directives:
      ssh-t [email protected]
      Try to connect to GitHub with SSH, you may see some warning messages:
      The authenticity of host ' github.com (192.30.252.1) ' can ' t be established. RSA Key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.are your sure you want to continue connecting (yes/n o)?
      Enter Yes whatever he is.
    3. If you see the message:
      Hi username! You ' ve successfully authenticated, and GitHub does not provide shell access
      It means the SSH connection is successful.
    4. If the message you received is "Access Denied", then you can refer to the link for further processing: https://help.github.com/articles/error-permission-denied-publickey/

Changing a remote ' s URL (change the URL of the repository)
After you set up SSH, you may need to change the URL of your remote repository from HTTPS to SSH (the advantage of SSH is that you don't have to lose your account password every time you push ...). ):
    1. Open git Bash
    2. Transfer the working directory to your local project
    3. To view the owned remote repositories:
      Git remote-v
    4. To change the URL of a remote repository:
      git remote Set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
      Origin is the warehouse name, followed by the SSH warehouse address:
    5. Check the owning remote repository to see if the modification was successful:
      Git remote-v

Now that GitHub's SSH key configuration is done, push never has to enter GitHub's account password every time ~

Github SSH key is created in configuration (Windows)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.