tutorials

在Ubuntu环境下配置git仓库

一、前言

鉴于Ubuntu上没有比较好用的GitCredentialManager,我决定改用SSH连接GitHub。

二、环境

三、步骤

生成密钥

ssh-keygen -t ed25519 -C "<你注册GitHub使用的邮箱>"

冷知识:上述代码中,-C "<你注册GitHub使用的邮箱>"其实是不必须的。

> Enter a file in which to save the key (/home/YOU/.ssh/id_ALGORITHM):[Press enter]

直接回车即可。

> Enter passphrase (empty for no passphrase): [Type a passphrase]

> Enter same passphrase again: [Type passphrase again]

添加密钥

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cd ~/.ssh

cat id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJGAJjMFzGzbhyRAX+2c9hngC8pBTU90QZa9xLLcM4KI liujingyu2020@outlook.com

开始推送

The authenticity of host 'github.com (*.*.*.*)' can't be established.
ED25519 key fingerprint is ******.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.

Git就会继续推送了。