How to generate SSH key

Source: Internet
Author: User
Tags ssh github ssh key

SSH key provides a way to communicate with GitHub in such a way that, without entering a password, GitHub can be used as its own remote server for versioning steps to check if SSH keys exist to generate a new SSH key Add SSH key to github how to generate SSH key 1. Check the existence of SSH keys

Enter the following command, if there is a file id_rsa.pub or id_dsa.pub, go directly to step 3 to add SSH key to GitHub, otherwise enter the second step to generate SSH key

Ls-al ~/.ssh
# Lists the files in your. SSH directory, if they exist
2. Generate a new SSH key

First step: Generate Public/private RSA key pair
Enter Ssh-keygen-t rsa-c "your_email@example.com" on the command line

By default, the Id_rsa and id_rsa.pub two files are generated under the corresponding path (/your_home_path), as shown in the following code

Ssh-keygen-t rsa-c "your_email@example.com"
# Creates a new SSH key using the provided email
generating public/p Rivate RSA key pair.
Enter file in which to save the key (/YOUR_HOME_PATH/.SSH/ID_RSA):

Step Two: Enter passphrase (this step can be skipped)

When you set up passphrase, when you do version control, you will be asked to enter passphrase each time you communicate with GitHub to avoid some "mistakes"

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Sample result:

Your identification has been saved In/your_home_path/.ssh/id_rsa.
Your public key has been saved in/your_home_path/.ssh/id_rsa.pub.
The key fingerprint is:
#01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Step Three: Add the newly generated key to the ssh-agent:

# Start the ssh-agent in the background
eval "$ (ssh-agent-s)"
agent pid 59566
ssh-add ~/.ssh/id_rsa
3. Add SSH key to GitHub

Open the Id_rsa.pub file with your favorite text editor, with the information in SSH key, and copy the information to GitHub's Add SSH key page


For some reason, the GitHub ssh Key needs to be regenerated, but the previous installation path cannot be found.

Fortunately I choose the default path, so to find the Id_rsa.pub file under the SSH folder, just need:

Open Terminal input

[plain] view Plain copy $ open ~/.ssh
Then, open the folder and you will find the Id_rsa.pub file.

Different operating systems, there are some commands to directly copy SSH key from the file to the Clipboard, as follows:

mac

Pbcopy < ~/.ssh/id_rsa.pub
# Copies The contents of the Id_rsa.pub file to your clipboard

Windows

Clip < ~/.ssh/id_rsa.pub
# Copies The contents of the Id_rsa.pub file to your clipboard

Linux

sudo apt-get install xclip
# Downloads and installs Xclip. If you don't have the ' apt-get ', you might need to use another installer (like ' yum ')

Xclip-sel clip < ~/.SSH/ID_RSA.P UB
# Copies The contents of the Id_rsa.pub file to your clipboard

In addition, the detailed operation of the GIT command can be referred to http://blog.csdn.net/cloudox_/article/details/46126247

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.