Linux server connects to github

Linux server connects to github

create ssh key

ssh-keygengenerate key using

-tIndicates the type of key generated, usually rsathe type of key generated

-bIndicates the length of the generated key, usually using 2048or4096

-fIndicates the location where the specified key pair file is generated. Under Linux, it is usually generated to ``/.ssh/my_key my_key` indicates the name of the key pair file, which can be modified according to the situation

For example, I want to create an ssh key pair to connect to github. This key pair is only used to connect to github, not for ssh services of other websites:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/github_key

There can be more than one key pair

If the name of the key pair file is not specified, and the key pair file is generated on the basis of the existing key pair file, then don't worry~

will not be overwritten!

If the key pair file already exists, ssh-keygena number will be appended to the filename to generate a unique filename, e.g. id_rsamay become id_rsa_2, id_rsa.pubmay become id_rsa_2.pub.

This is done to avoid accidentally overwriting existing key pair files. By keeping the old key pair file, you can continue to connect using the existing public key, or manually switch to the new key pair when needed.

Put the public key on github

Use cat/ moreview github_key.pub, then copy to github to connect

cat ~/.ssh/id_rsa.pub
  • Log in to your GitHub account, click on your avatar in the upper right corner, and select "Settings".
  • In the left navigation, select "SSH and GPG keys".
  • Click the "New SSH key" button.
  • In the Title field, provide a descriptive name for the key.
  • Paste the contents of the public key you copied from the previous step into the "Key" field.
  • Finally, click the "Add SSH key" button.

enterssh -T [email protected]

verify connection

Appear

Hi ~~!You've successfully authenticated, but GitHub does not provide shell access.can

Guess you like

Origin blog.csdn.net/ahahayaa/article/details/131555967