The company recently decided to move all of its projects to a Git repository, and we use Gogs (an open source solution).

I signed up for my account on Gogs, and next I went to set up my SSH key.

When I opened the local id_rsa.pub file (I used Github before and have generated SSH key, please click here if not), I found my email address at the end of the key, which is my email address when I registered Github.

There was some reluctance to enter the SSH public key into the Gogs repository because the SSH key was generated for Github.

Reluctantly, but in order not to delay progress, I entered this SSH public key into the SSH key Settings for the Gogs repository.

Next, submit code, everything is all right, but when I check the submission history, every time I found that I submit the user name is my own set up a English name, this is awkward, the English name is originally to protect their privacy, dedicated to making Settings, if use this English name, that the company is not very convenient.

Thinking of the Gogs SSH key issue above, I decided to set up a dedicated SSH key and commit username for the company’s Gogs repository.

The intermediate process is not detailed, I consulted colleagues and Baidu, summed up the operation method.

Generate another SSH key

Open the git command line and type the following command:

ssh-keygen -t rsa -C “[email protected]” -f ~/.ssh/your_new_ssh

Press Enter to generate a new SSH key, your_new_ssh (private key) and your_new_ssh.pub (public key).

The.ssh folder now has two pairs of public and private keys. You need a rule that specifies which one Github uses and which one Gogs uses. Open a new config file in.ssh (no suffix) and write the following inside:

Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/. SSH /id_rsa Host Your Gogs address HostName PreferredAuthentications publickey IdentityFile ~/.ssh/your_new_sshCopy the code

Github access is id_RSA and Gogs is your_new_ssh.

Specify the user name at commit time

This is also easy to set in the corporate project folder to ensure that only corporate projects work.

git config user.name “your_name”