最近在家里电脑提交代码时候提示
λ git pull
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
看一下ssh config吧。
λ cat ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile D:\Envs\dotFile\id_ed25519
IdentitiesOnly yes
下面逐行解释:
Host github.com
一个别名,用于一个或多个服务器。可以使用任何名称,这只是一个标识符。Host github.com
定义了一个别名 github.com,可以在使用 SSH 命令时使用这个别名来代替实际的主机名或 IP 地址。
Hostname github.com
实际的主机名或 IP 地址,当使用 github.com 这个别名时,SSH 将连接到 HostName 字段指定的地址。
User git
说明该配置的用户是git
IdentityFile D:\Envs\dotFile\id_ed25519
指定了该使用哪个ssh私钥
IdentitiesOnly yes
设置为 yes 时,SSH 客户端只会使用 IdentityFile 指定的密钥,而不会使用 ssh-agent 中的任何其他密钥。这可以帮助避免尝试太多密钥导致的问题。
评论区