git与ssh配置方法及注意事项

git与ssh配置方法及注意事项

配置ssh key

  1. 生成ed25519密钥
    ssh-keygen -t ed25519 -C YOUR_EMAIL

use your real email value instead of YOUR_EMAIL

将私钥添加到身份验证代理
ssh-add

  1. ~/.ssh/id_ed25519.pub的文本添加到gerritgit用户配置的SSH keys
  • cat ~/.ssh/id_ed25519.pub
  • Click the setting button
  • Click the SSH Public Keys button
  • Click the Add key button
  • Add the info of the public key and save.
  1. 可以在~/.ssh/config配置文件中指定认证选项,明确指定认证文件(不是必须的)
    比如:
Host your.gerrit.host
IdentityFile ~/.ssh/id_ed25519
  1. 或者在~/.ssh/config配置文件中指定客户端接受RSA密钥(不推荐)
PubkeyAcceptedKeyTypes +ssh-rsa

Host *
ServerAliveInterval 120

IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_rsa
PubkeyAcceptedKeyTypes +ssh-rsa
  1. verify whether the ssh config is ok
    ssh -p 29418 USER@SERVER_IP
    or add -vv option to see detailed information.
    ssh -vv -p 29418 USER@SERVER_IP

  2. config git

  • config username and email
git config --global user.name  YOUR_USERNAME
git config --global user.email YOUR_EMAIL

use your real github or gerrit username instead of YOUR_USERNAME, No square brackets
use your real email value instead of YOUR_EMAIL, No square brackets

  • config editor
git config --global core.editor vim
  • set commit template
git config --global commit.template ~/.git.commit.template.txt

edit commit template file, eg: ~/.git.commit.template.txt

[id][platform][module] short message

Release note:
-problem:
-solution:
-author:
-reviewer:

Test:
1.
2.

版权声明:本文为halazi100原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。