我从未遇到过 ssh 工作和 git 不以这种方式工作的情况。不知道如何排除故障。
ssh 似乎工作(-T防止第一行):
iam@heeere:/e/.ssh$ ssh github
PTY allocation request failed on channel 0
Hi bradyt! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
Run Code Online (Sandbox Code Playgroud)
git push 似乎不起作用
iam@heeere:/e/basic-computing-notes$ git push
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我的 git 配置是
iam@heeere:/e/basic-computing-notes$ git config -l
user.email=algebrat@uw.edu
user.name=Brady Trainor
push.default=simple
alias.ac=!git add --all && git commit
alias.lol=log --oneline --graph --decorate --all
core.editor=vim
core.excludesfile=/e/configs/.gitignore_global
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:bradyt/basic-computing-notes.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
Run Code Online (Sandbox Code Playgroud)
我的 ssh 配置包括
Host github
HostName github.com
User git
IdentityFile "~/.ssh/github_rsa"
Run Code Online (Sandbox Code Playgroud)
由于您的 ssh 密钥没有默认名称 ( id_rsa, id_rsa.pub),您需要使用您定义的 ssh 配置条目,以便您的 ssh url 引用正确的密钥:
git remote set-url origin github:bradyt/basic-computing-notes.git
Run Code Online (Sandbox Code Playgroud)
这样,ssh 将寻找~/.ssh/github_rsa,而不是寻找~/.ssh/id_rsa。
更简单的是,musiKk在评论中建议,将 ssh 配置的条目更改为github.com.
Host github.com github
HostName github.com
User git
IdentityFile "~/.ssh/github_rsa"
Run Code Online (Sandbox Code Playgroud)
我保留了Hostname和User只是为了确定,但默认 url 将起作用 ( git@github.com:bradyt/basic-computing-notes.git)
正如raphinesse在评论中提到的:
如果您仍然想使用快捷方式
github,Host关键字允许多种模式。
从ssh_config手册页:如果提供了多个模式,它们应该用空格分隔。
| 归档时间: |
|
| 查看次数: |
2539 次 |
| 最近记录: |