Home > Development Tools > git > How to set up ssh on github

How to set up ssh on github

PHPz
Release: 2023-04-26 10:08:00
Original
6194 people have browsed it

GitHub is a platform that supports code hosting. General code warehouses need to be accessed through usernames and passwords, which is not only cumbersome but also easy to leak passwords; SSH can be used to securely connect and push code, strengthening the security of the code warehouse. Management, here's how to configure SSH on GitHub.

1. What is SSH

SSH (Secure Shell Protocol) is a protocol for remote login and secure data transmission. Simply put, it is a protocol that provides secure transmission on the network. SSH is a secure transfer protocol that encrypts network connections and securely transmits data over such connections. In practical applications, SSH is mainly used to connect to the server, log in to the server, upload and download files, etc.

2. Why use SSH

Compared with using ordinary user names and passwords to access the code warehouse, using SSH has the following advantages:

  1. Security High sex. SSH is an encrypted protocol that ensures the privacy and security of data transmission.
  2. Convenient. Using SSH makes it easy and fast to upload and download code without having to enter your username and password every time.
  3. Simple configuration. After configuring SSH once, you can upload and download code in the future without entering the password again.

Therefore, in order to protect the security of the GitHub code repository and to upload and download code conveniently and quickly, it is very necessary to configure SSH.

3. Generate SSH keys

The following describes how to generate SSH keys in Linux or MacOS.

  1. Open the terminal;
  2. Enter the following command:

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    Copy after login

    Note:

    -t indicates the algorithm type, here the RSA algorithm is used ;

    -b indicates the key length, 4096 bits are used here;

    -C indicates adding comment information, here is your email address.

  3. Follow the prompts and enter the save path and file name. Generally, there is no need to change it, just press Enter to confirm;
  4. You can choose not to set a password during the key generation process, so that every time you use SSH There is no need to enter a password at all times, but this will slightly reduce security.
  5. After successful generation, an id_rsa file and an id_rsa.pub file will be generated in the folder. id_rsa is a private key file and cannot be leaked; id_rsa.pub is a public key file and can be shared with others with confidence. or website use.

4. Add the public key file to GitHub

  1. Open the GitHub website, enter your personal homepage, and click the Settings icon;
  2. Click on the left menu SSH and GPG keys in the column;
  3. Click New SSH key, enter Title and Key, where the content in Key is all the contents in the id_rsa.pub file you generated in the previous step;
  4. Click Add SSH key to complete the addition.

5. Test SSH connection

To verify whether SSH is configured successfully, you need to test it on the terminal. The specific method is as follows:

  1. Open the terminal , enter the following command:

    ssh -T git@github.com
    Copy after login
  2. Enter yes according to the prompt to confirm;
  3. If the following information appears, it means the SSH connection is successful:

    Hi {your_username}! You've successfully authenticated, but GitHub does not provide shell access.
    Copy after login

    At this point, SSH has been configured.

6. Summary

The above are the detailed steps on how to configure SSH on GitHub. SSH is a safe and effective connection method that is not only convenient and fast, but also protects The security of GitHub code repository, I hope this article will be helpful to everyone.

The above is the detailed content of How to set up ssh on github. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template