no such identity: /Users/weixiongwei/.ssh/github_ed25519: No such file or directory
[email protected]: Permission denied (publickey).
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
生成密钥对
ssh-keygen -t ed25519 -C "[email protected]"
Note: If you are using a legacy system that doesn't support the Ed25519 algorithm, use:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
This creates a new SSH key, using the provided email as a label.
> Generating public/private algorithm key pair.
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
> Enter a file in which to save the key (/Users/you/.ssh/id_algorithm): [Press enter]
At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases."
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
将本机生成的ssh key复制到个人GitHub账户中去。
本机账户文件夹下找到id_rsa.pub,以text方式打开,复制内容。
要在 GitHub.com 上配置帐户以使用新的(或现有的)SSH 密钥,还需要将密钥添加到帐户。
MacWindowsLinux
GitHub CLIWeb browser
在将新的 SSH 密钥添加到 GitHub.com 上的帐户之前,您应该具有:
在向您在 GitHub.com 上的帐户添加新 SSH 密钥后,您可以重新配置任何本地存储库以使用 SSH。 更多信息请参阅“将远程 URL 从 HTTPS 转换为 SSH”。
Note: GitHub improved security by dropping older, insecure key types on March 15, 2022.
As of that date, DSA keys (ssh-dss
) are no longer supported. You cannot add new DSA keys to your user account on GitHub.com.
RSA keys (ssh-rsa
) with a valid_after
before November 2, 2021 may continue to use any signature algorithm. RSA keys generated after that date must use a SHA-2 signature algorithm. Some older clients may need to be upgraded in order to use SHA-2 signatures.
将 SSH 公钥复制到剪贴板。
如果您的 SSH 公钥文件与示例代码不同,请修改文件名以匹配您当前的设置。 在复制密钥时,请勿添加任何新行或空格。
$ pbcopy < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard
提示:如果 pbcopy
不可用,可找到隐藏的 .ssh
文件夹,在常用的文本编辑器中打开该文件,并将其复制到剪贴板。
在任何页面的右上角,单击您的个人资料照片,然后单击 Settings(设置)。
In the "Access" section of the sidebar, click SSH and GPG keys.
单击 New SSH key(新 SSH 密钥)或 Add SSH key(添加 SSH 密钥)。
在 "Title"(标题)字段中,为新密钥添加描述性标签。 例如,如果您使用的是个人 Mac,此密钥名称可能是 "Personal MacBook Air"。
将密钥粘贴到 "Key"(密钥)字段。
单击 Add SSH key(添加 SSH 密钥)。
如有提示,请确认您的 GitHub 密码。
ssh -T [email protected]
解决方案:
ssh-add -k ~/.ssh/id_rsa
如果出现下面的问题:
解决方案:
sudo chmod 0600 ~/.ssh/id_rsa
再次执行:
ssh -T [email protected]
如下图则配置成功
参考链接:
Permissions 0644 for '/Users/henryj/.ssh/id_dsa' are too open. 错误解决方案_青春燃烧的岁月的博客-CSDN博客
github提示Permission denied (publickey),如何才能解决? - 知乎
解决[email protected]: Permission denied (publickey). Could not read from remote repository_ywl470812087的博客-CSDN博客
[email protected]: Permission denied (publickey). fatal: Could not read from remote repository. - ckx0709 - 博客园