Introduction

Due to personal reasons, I need to deploy two Hexo blogs on one computer. I thought it was quite simple, but I didn’t expect that there are many problems. First of all, one GitHub account can only build one Hexo blog (updates, it is said that Github Pages now supports the creation of one account) Multiple Pages, you can try it if you are interested), so you need to use other GitHub accounts; secondly, if one computer binds two GitHub accounts, you need two pairs of public keys, which is encountered when dealing with the second problem There are many questions. Because I know nothing about this aspect and am still a novice, I struggled all afternoon to solve it. I couldn’t understand many tutorials on the Internet and felt that they were not (self) detailed (too) detailed (stupid) enough. Record it in detail

Principle analysis:

  • The SSH public key is the unique identifier for GitHub as a connection between the local warehouse and the remote warehouse. One public key can only correspond to one GitHub account. If the same public key is uploaded to different GitHub accounts, GitHub will not be able to identify it, which will lead to mistake
  • A computer can generate multiple pairs of public and private keys. Different public keys can be uploaded to different GitHub accounts through configuration, so there is no need to bind a single public key to multiple GitHub accounts.

Related issues reported:

  • When deploying a second Hexo blog on the same computer and executing hexo g -d, an error message appears: ERROR: Permission to xxxxxx/xxxxxx.github.io.git denied to xxxxxx.
  • Add a new SSH key to the SSH agent. When executing ssh-add xxx, an error message appears: Could not open a connection to your authentication agent.
  • When setting the username/email separately, an error occurs: fatal: not in a git directory