完整教程:GitHub 新建项目操作指南
<style>pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; line-height: 1.6 !important; padding: 16px !important; margin: 16px 0 !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; tab-size: 4 !important; -moz-tab-size: 4 !important; max-width: 100% !important; box-sizing: border-box !important }code { font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; overflow-wrap: normal !important; display: inline !important; background: rgba(0, 0, 0, 0) !important; border: none !important; padding: 0 !important; margin: 0 !important; line-height: inherit !important }
pre code { background: rgba(0, 0, 0, 0) !important; border: 0 !important; border-radius: 0 !important; display: block !important; line-height: 1.6 !important; margin: 0 !important; max-width: none !important; overflow: visible !important; padding: 0 !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; color: inherit !important }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: rgba(112, 128, 144, 1) !important; font-style: italic !important }
.token.punctuation { color: rgba(153, 153, 153, 1) !important }
.token.atrule, .token.attr-value, .token.keyword { color: rgba(0, 119, 170, 1) !important; font-weight: bold !important }
.token.function, .token.class-name { color: rgba(221, 74, 104, 1) !important; font-weight: bold !important }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: rgba(102, 153, 0, 1) !important }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: rgba(153, 0, 85, 1) !important }
.cnblogs-markdown pre, .cnblogs-post-body pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; padding: 16px !important; margin: 16px 0 !important }
pre, pre, pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important }</style>
<div class="htmledit_views atom-one-dark" id="content_views"><h2>GitHub 新建项目的详细操作步骤,适用于网页版</h2><hr><h3>一、准备工作</h3><ol><li><p><strong>注册/登录 GitHub 账号</strong></p></li><li><p><strong>准备项目相关材料</strong></p><ul><li><p>项目名称</p></li><li><p>项目描述(可选)</p></li><li><p>README 文件内容</p></li><li><p>.gitignore 模板(可选)</p></li><li><p>开源许可证(可选)</p></li></ul></li></ol><hr><h3>二、创建新仓库</h3><h4><strong>从零开始创建</strong></h4><ol><li><p><span style="color: rgba(254, 44, 36, 1)">登录 GitHub,点击右上角 <strong>+</strong> 图标</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">选择 <strong>New repository</strong></span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">填写仓库信息:</span></p><ul><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Repository name</strong>: 项目名称(如 <code>my-project</code>)</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Description</strong>: 项目描述(可选)</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Visibility</strong>:</span></p><ul><li><p><span style="color: rgba(254, 44, 36, 1)">Public(公开,免费)</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">Private(私有,免费用户可用)</span></p></li></ul></li><li><p><strong>初始化选项</strong>(保持默认):</p><ul><li><p>✅ Add a README file(添加说明文档)</p></li><li><p>✅ Add .gitignore(选择模板:如 Python、Node 等)</p></li><li><p>✅ Choose a license(选择开源协议:如 MIT、Apache 等)</p></li></ul></li></ul></li><li><p>点击 <strong>Create repository</strong></p></li></ol><hr><h3>三、本地连接与操作</h3><h4><strong>情况一:本地已有项目代码</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 1. 进入项目目录
cd your-project
# 2. 初始化 Git
git init
# 3. 添加远程仓库
git remote add origin https://github.com/用户名/仓库名.git
# 4. 添加文件并提交
git add .
git commit -m "Initial commit"
# 5. 推送到 GitHub
git branch -M main
git push -u origin main</code></pre>
<hr><h4><strong>情况二:从零开始新项目</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 1. 克隆空仓库到本地
git clone https://github.com/用户名/仓库名.git
cd 仓库名
# 2. 创建项目文件
# ... 编写代码 ...
# 3. 提交更改
git add .
git commit -m "添加功能"
git push origin main</code></pre>
<hr><h3>四、仓库设置建议</h3><ol><li><p><strong>添加协作成员</strong>(私有仓库):</p><ul><li><p>Settings → Collaborators → Add people</p></li></ul></li><li><p><strong>设置分支保护规则</strong>:</p><ul><li><p>Settings → Branches → Add rule</p></li></ul></li><li><p><strong>配置项目页面</strong>:</p><ul><li><p>Settings → Pages → 选择分支和文件夹</p></li></ul></li><li><p><strong>管理 Webhooks 和集成</strong>(可选)</p></li></ol><hr><h3>五、快速操作技巧</h3><ul><li><p><strong>通过命令行创建</strong>(需要 GitHub CLI):</p><p>bash</p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>gh repo create 仓库名 --public --clone</code></pre> </li><li><p><strong>从现有代码导入</strong>:</p><ul><li><p>在仓库页面点击 <strong>Import code</strong></p></li></ul></li><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>使用 GitHub Desktop</strong>:</span></p><ol><li><p><span style="color: rgba(254, 44, 36, 1)">安装 GitHub Desktop</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">File → New repository</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">同步到 GitHub</span></p></li></ol></li></ul><hr><h3>常见问题</h3><ol><li><p><strong>推送失败</strong>:检查远程地址和权限</p></li><li><p><strong>文件忽略无效</strong>:确认 .gitignore 语法正确</p></li><li><p><strong>许可证选择</strong>:根据项目需求选择合适的开源协议</p></li></ol><hr><h3>下一步建议</h3><ul><li><p>完善 README.md(项目介绍、安装、使用说明)</p></li><li><p>添加 Issues 模板</p></li><li><p>设置 CI/CD 工作流程</p></li><li><p>创建第一个版本 Release</p></li></ul><hr><h2>推送失败:SSH 公钥认证被拒绝(git@github.com 权限不足)并且主机密钥已添加到 ~/.ssh/known_hosts。</h2><hr><p>SSH 公钥认证被拒绝是常见的权限问题。以下是详细的排查和解决方案:</p><hr><h3>一、问题诊断步骤</h3><h4><strong>1. 检查 SSH 密钥是否存在</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 查看本地是否有 SSH 密钥
ls -al ~/.ssh/
# 应该能看到 id_rsa 和 id_rsa.pub(或 id_ed25519 等)</code></pre>
<h4><strong>2. 测试 SSH 连接</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh -T git@github.com</code></pre>
<p><strong>预期成功响应</strong>:</p><p>text</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>Hi 你的用户名! You've successfully authenticated...</code></pre>
<p><strong>错误响应</strong>:</p><ul><li><p><code>Permission denied (publickey)</code>:密钥未正确配置</p></li><li><p><code>Host key verification failed</code>:known_hosts 问题</p></li></ul><hr><h3>二、解决方案</h3><h4><strong>方案 A:重新添加公钥到 GitHub</strong></h4><ol><li><p><strong>复制公钥内容</strong>:</p><p>bash</p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 复制 RSA 密钥
cat ~/.ssh/id_rsa.pub
# 或者 ed25519 密钥
cat ~/.ssh/id_ed25519.pub</code></pre> <p><strong>注意</strong>:复制 <code>.pub</code> 文件内容,格式类似:</p><p>text</p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh-rsa AAAAB3NzaC1yc2EAAA... 你的邮箱</code></pre> </li><li><p><strong>在 GitHub 添加公钥</strong>:</p><ul><li><p>登录 GitHub → Settings → SSH and GPG keys</p></li><li><p>点击 <strong>New SSH key</strong></p></li><li><p><strong>Title</strong>:自定义名称(如 "My Laptop")</p></li><li><p><strong>Key</strong>:粘贴刚才复制的公钥内容</p></li><li><p>点击 <strong>Add SSH key</strong></p></li></ul></li></ol><hr><h4><strong>方案 B:生成新的 SSH 密钥</strong></h4><p>如果现有密钥无效或丢失:</p><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 1. 生成新密钥(推荐 ed25519)
ssh-keygen -t ed25519 -C "your_email@example.com"
# 或使用 RSA
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# 2. 一路回车使用默认设置
# 3. 启动 SSH 代理
eval "$(ssh-agent -s)"
# 4. 添加私钥到代理
ssh-add ~/.ssh/id_ed25519# 或 id_rsa
# 5. 复制公钥并添加到 GitHub(如方案 A 步骤)
cat ~/.ssh/id_ed25519.pub | pbcopy# macOS
cat ~/.ssh/id_ed25519.pub | clip # Windows
cat ~/.ssh/id_ed25519.pub # Linux,手动复制</code></pre>
<hr><h4><strong>方案 C:检查 known_hosts 文件</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 1. 删除旧的 GitHub 主机密钥
ssh-keygen -R github.com
# 2. 重新添加
ssh-keyscan github.com >> ~/.ssh/known_hosts</code></pre>
<hr><h3>三、验证和测试</h3><h4><strong>1. 测试 SSH 连接</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh -T git@github.com -v</code></pre>
<p><code>-v</code> 参数显示详细调试信息,帮助定位问题。</p><h4><strong>2. 检查 Git 远程 URL</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 查看当前远程地址
git remote -v
# 如果不是 SSH 格式,修改为 SSH
git remote set-url origin git@github.com:用户名/仓库名.git
# 从 HTTPS 切换到 SSH 的示例:
git remote set-url origin git@github.com:username/repo.git</code></pre>
<h4><strong>3. 多密钥配置(如果使用多个 GitHub 账号)</strong></h4><p>在 <code>~/.ssh/config</code> 文件中添加:</p><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 编辑配置文件
nano ~/.ssh/config
# 添加以下内容
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
# 使用不同的远程 URL
git remote set-url origin git@github.com-work:公司账号/仓库名.git</code></pre>
<h3>四、常见错误及解决</h3><h4><strong>错误 1:Agent admitted failure</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 解决方案
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa# 或你的私钥文件</code></pre>
<h4><strong>错误 2:Permissions are too open</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 修复文件权限
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/known_hosts</code></pre>
<h4><strong>错误 3:Windows 特定问题</strong></h4><ol><li><p><strong>确保 OpenSSH 服务运行</strong>:</p><p>powershell</p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 管理员 PowerShell
Get-Service ssh-agent
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent</code></pre> </li><li><p><strong>使用 Git Bash</strong> 替代 PowerShell</p></li></ol><h3>五、快速检查清单</h3><ul><li><p>SSH 密钥已生成且存在</p></li><li><p>公钥已添加到 GitHub</p></li><li><p>SSH 代理正在运行</p></li><li><p>私钥已添加到代理</p></li><li><p>Git 远程 URL 是 SSH 格式</p></li><li><p>文件权限正确</p></li></ul><h3>六、备用方案:使用 HTTPS</h3><p>如果 SSH 问题暂时无法解决,可临时使用 HTTPS:</p><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 切换为 HTTPS
git remote set-url origin https://github.com/用户名/仓库名.git
# 推送时使用个人访问令牌(PAT)
# 在 GitHub Settings → Developer settings → Personal access tokens 生成
git push origin main
# 输入用户名,密码处粘贴 PAT</code></pre>
<h3>七、调试命令汇总</h3><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 完整调试流程
ssh -T git@github.com -v # 详细调试
ssh-add -l # 列出加载的密钥
cat ~/.ssh/config 2>/dev/null || echo "无配置文件"# 检查配置
git config --get remote.origin.url # 检查远程 URL</code></pre>
<hr><p>total 12 drwx------ 2 mumu mumu 4096 Dec 12 13:07 . drwxr-x--- 13 mumu mumu 4096 Dec 12 13:07 .. -rw-r--r-- 1 mumu mumu 142 Dec 12 13:07 known_hosts</p><hr><h2>你的 SSH 目录只有 <code>known_hosts</code> 文件</h2><p><span style="color: rgba(254, 44, 36, 1)">说明<strong>还没有生成 SSH 密钥对</strong>。</span>这是问题的根本原因。让我们一步步解决:</p><hr><h3>一、生成新的 SSH 密钥</h3><h4><strong>1. 生成密钥对</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 使用 ed25519 算法(更安全、更快)
ssh-keygen -t ed25519 -C "你的邮箱@example.com"
# 或者使用 RSA 算法(兼容性更好)
# ssh-keygen -t rsa -b 4096 -C "你的邮箱@example.com"</code></pre>
<p><span style="color: rgba(254, 44, 36, 1)">执行上述命令后:</span></p><ol><li><p><span style="color: rgba(254, 44, 36, 1)">按 Enter 接受默认保存路径(<code>~/.ssh/id_ed25519</code>)</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">设置密码(可选):可以为空直接按 Enter</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">再次确认密码(如果设置了)</span></p></li></ol><h4><strong>2. 验证密钥生成</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 查看生成的密钥文件
ls -la ~/.ssh/
# 应该能看到:
# - id_ed25519 (私钥,权限 600)
# - id_ed25519.pub(公钥,权限 644)
# - known_hosts</code></pre>
<h3>二、添加 SSH 密钥到代理</h3><h4><strong>1. 启动 SSH 代理</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 启动代理
eval "$(ssh-agent -s)"
# 应该看到类似:Agent pid 12345</code></pre>
<h4><strong>2. 添加私钥到代理</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 添加 ed25519 密钥
ssh-add ~/.ssh/id_ed25519
# 如果使用 RSA
# ssh-add ~/.ssh/id_rsa</code></pre>
<h4><strong>3.<span style="color: rgba(254, 44, 36, 1)"> 验证密钥已加载</span></strong></h4><p><span style="color: rgba(254, 44, 36, 1)">bash</span></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh-add -l
# 应该显示指纹信息,如:256 SHA256:xxxxxxxxxx your_email@example.com (ED25519)</code></pre>
<h3>三、将公钥添加到 GitHub</h3><h4><strong>1. 复制公钥内容</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 显示公钥内容并复制
cat ~/.ssh/id_ed25519.pub</code></pre>
<p><strong>公钥内容格式</strong>:</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... 你的邮箱@example.com</code></pre>
<p><span style="color: rgba(254, 44, 36, 1)"><strong>复制全部内容</strong>(以 <code>ssh-ed25519</code> 开头,邮箱结尾)</span></p><hr><h4><strong>2. <span style="color: rgba(254, 44, 36, 1)">添加到 GitHub</span></strong></h4><ol><li><p><span style="color: rgba(254, 44, 36, 1)">打开浏览器登录 GitHub</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">点击右上角头像 → <strong>Settings</strong></span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">左侧菜单选择 <strong>SSH and GPG keys</strong></span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">点击 <strong>New SSH key</strong></span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)">填写:</span></p><ul><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Title</strong>:自定义(如 "My Laptop")</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Key type</strong>:保持默认 Authentication Key</span></p></li><li><p><span style="color: rgba(254, 44, 36, 1)"><strong>Key</strong>:粘贴刚才复制的公钥内容</span></p></li></ul></li><li><p><span style="color: rgba(254, 44, 36, 1)">点击 <strong>Add SSH key</strong></span></p></li></ol><hr><h3>四、测试 SSH 连接</h3><h4><strong>1. <span style="color: rgba(254, 44, 36, 1)">测试 GitHub 连接</span></strong></h4><p><span style="color: rgba(254, 44, 36, 1)">bash</span></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>ssh -T git@github.com</code></pre>
<p><strong>成功响应</strong>:</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>Hi 你的用户名! You've successfully authenticated, but GitHub does not provide shell access.</code></pre>
<h4><strong>2. 如果仍然失败,清理 known_hosts</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 删除旧的 GitHub 主机密钥
ssh-keygen -R github.com
# 重新连接,会自动添加
ssh -T git@github.com</code></pre>
<h3>五、配置 Git 使用 SSH</h3><h4><strong>1. <span style="color: rgba(254, 44, 36, 1)">检查当前远程地址</span></strong></h4><p><span style="color: rgba(254, 44, 36, 1)">bash</span></p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>cd 你的项目目录
git remote -v</code></pre>
<hr><h4><strong>2. 如果是 HTTPS,切换为 SSH</strong></h4><p><span style="color: rgba(254, 44, 36, 1)"><strong>看情况,不一定要切换。</strong></span></p><blockquote><p>推送失败:SSH 公钥认证被拒绝(git@github.com 权限不足)并且主机密钥已添加到 <code>~/.ssh/known_hosts</code>。</p><p>可选操作(请回复选择一项):</p><ul><li><span style="color: rgba(13, 0, 22, 1)">我帮你改用 HTTPS URL 并推送(我会将 remote 设置为 <code>https://github.com/IreneJinqiu/Vue3-study.git</code> 并尝试推送;可能需要输入凭据)。</span></li><li><span style="color: rgba(254, 44, 36, 1)"><strong>你提供已配置的 SSH key 或在当前环境配置 SSH 后我再重试。</strong></span></li><li>我只把远程添加好(现在已经设置为 <code>git@github.com:IreneJinqiu/Vue3-study.git</code>),你在本地处理认证后再推送。
<hr><p><span style="color: rgba(254, 44, 36, 1)"><strong>已配置 SSH key,重试</strong></span></p><hr><p>现在我将确认当前分支并使用已配置的 SSH key 推送到 <code>origin</code>(检查分支、执行 <code>git push</code>)。</p><p>git branch --show-current</p></li><li></li><li></li><li><p>git push -u origin master</p></li><li></li><li><p>已完成:当前分支 <code>master</code> 已成功推送到远程 <code>origin</code>(git@github.com:IreneJinqiu/Vue3-study.git),并设置为跟踪 <code>origin/master</code>。</p></li><li></li></ul></blockquote><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 格式:git@github.com:用户名/仓库名.git
git remote set-url origin git@github.com:你的用户名/仓库名.git
# 示例:
# git remote set-url origin git@github.com:mumu/my-project.git</code></pre>
<hr><h4><strong>3. 测试推送</strong></h4><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>git push origin main</code></pre>
<hr><h3>六、完整命令序列(直接复制执行)</h3><p>bash</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code># 1. 生成 SSH 密钥(使用你的邮箱)
ssh-keygen -t ed25519 -C "mumu@example.com"
# 一路按 Enter,使用默认设置
# 2. 启动 SSH 代理
eval "$(ssh-agent -s)"
# 3. 添加密钥
ssh-add ~/.ssh/id_ed25519
# 4. 显示公钥(复制全部内容)
cat ~/.ssh/id_ed25519.pub
# 5. 测试连接
ssh -T git@github.com
# 6. 进入项目目录,切换到 SSH
cd ~/你的项目路径
git remote set-url origin git@github.com:你的用户名/仓库名.git
git push origin main</code></pre>
<hr><h3>七、快速排查</h3><p>如果还有问题,检查以下几点:</p><ol><li><p><strong>文件权限是否正确</strong>:</p><p>bash</p> <pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code>chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub</code></pre> </li><li><p><strong>检查是否使用 VPN 或代理</strong>:有些网络会拦截 SSH</p></li><li><p><strong>多账号配置</strong>:如果使用多个 GitHub 账号,需要配置 <code>~/.ssh/config</code></p></li></ol><hr><p><strong><span style="color: rgba(254, 44, 36, 1)">请先执行第 1-4 步(生成密钥并添加到 GitHub)</span>,然后告诉我测试 <code>ssh -T git@github.com</code> 的结果</strong>,我会根据具体错误进一步帮助您。</p></div><br><br>
来源:https://www.cnblogs.com/clnchanpin/p/19475415
頁:
[1]