使用 Git 的 SSH 密钥

SSH key using Git

我是 GitHub 的新手,在学习 this tutorial 之后,我正在尝试了解 SSH 密钥。

我已经创建了一个密钥并将其添加到我的帐户中。目前,我只有几个测试存储库,我在本地克隆了这些存储库。

现在,问题是,即使我没有设置我的 ssh-agent(或者我从 GitHub 中删除了所有密钥),我仍然可以更新我的存储库并推送给它们。

我唯一无法使用经过验证的密钥做的事情是使用 SSH link(例如 git@github.com:username/repository.git)克隆存储库,但我仍然可以使用 https 克隆并推送到存储库link(例如 https://github.com/username/repository.git)。

我最初thought允许使用 https 进行克隆,但我无法推送,但我什至可以推送并且它不询问任何用户名和密码!

那么,如果任何人仍然可以像我使用经过验证的密钥那样做同样的事情,那么 SSH 密钥的用途是什么? 与特权和权限有关吗?

but I can still clone and push to repositories using the https link (e.g. https://github.com/username/repository.git).

使用 HTTPS 时,您不会使用任何 SSH 密钥,仅使用 git 凭据助手 (git config credential.helper)

printf "protocol=https\nhost=github.com"|git credential-xxx erase

git config credential.helper

返回的助手替换xxx