赞
踩
参考官方文档: Link
远程 URL 是 Git 一种指示“代码存储位置”的绝佳方式。用户只能推送到两类 URL 地址:
https://github.com/user/repo.git
git@github.com:user/repo.git
(推荐使用)HTTPS URL 在所有存储库上都可用,在命令行上使用 HTTPS URL 对远程仓库执行 git clone、git fetch、git pull 或 git push 时,Git 将要求你提供 GitHub 用户名和密码。
SSH URL 通过 SSH(一种安全协议)提供 Git 仓库的访问权限。 若要使用这个 URL,必须在PC上生成 SSH 密钥对,并将“公共”密钥添加到你的 GitHub 帐户中。
如果不在GiHub 账户中添加公钥,则会在 git clone 的时候输出下面的报错信息。
参考官方文档: Link
Windows 和 Linux 以下内容同理
有三种身份验证方式:
参考官方文档: Link
具体配置参考上述文档,很少用到就不搞了。
参考官方文档: Link
ls -al ~/.ssh
检查目录列表以查看是否已经有 SSH 公钥。
默认情况下,GitHub 的一个支持的公钥的文件名是以下之一: id_rsa.pub、id_ecdsa.pub、id_ed25519.pub
ssh-keygen -t ed25519 -C "your_email@example.com"
C:\Users\{username}\.ssh
找到生成的私钥和公钥(pub文件)eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
Setting
中找到 SSH and GPG keys
,点击 New SSH key
Key
中填刚刚复制的公钥内容ssh -T git@github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
ssh: connect to host github.com port 22: Connection timed out
,则通过 HTTPS 端口使用 SSH官方文档: Link
在 .ssh/config
文件中加入以下内容:
Host github.com
Hostname ssh.github.com
Port 443
User git
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。