我在使用中遇到了一个问题 ssh
来连接到github。
我在我的项目中配置了一个远程,我看到它使用了 git remote -v
.
当我执行命令时 git push origin master
错误是。
$ git push origin master
ERROR: Repository not found.
fatal: could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
我该如何解决这个问题?
非常感谢。
你需要为你的git账户添加认证密钥。
只要按照这些步骤,你就能很快设置好你的ssh密钥。
生成一个新的ssh密钥(如果你已经有一个密钥,则跳过这一步)。ssh-keygen -t rsa -C "your@email"
一旦你有了你的钥匙,在 home/.ssh
目录 Users/<your user>.ssh
(在windows下),打开它,并将内容复制到
SSH keys
Add ssh key
然后你就可以开始了 :-)
步骤1:生成KEY
- cd ~/.ssh
- ssh-keygen -t rsa -b 4096 -C "[email protected]"
注意 - 密钥必须只有你自己可以读。
chmod 400 ~.sshid_rsa
如果密钥需要被你读写。
chmod 600 ~.sshid_rsa
第二步:检查内容并复制
- cat ~/.ssh/nameOfFile.pub | pbcopy
第3步:将你的SSH密钥配置到Bitbucket.org中(类似适用于Github.com) GOTO settings => SSHKEY
- Add what you copied in Step 2 and give it a name
第4步:使用SSH协议克隆你的存储库。
- git clone [email protected]:{username}/repo.git
- git clone [email protected]:{username}/repo.git
这应该是可行的,但是
如果你一直收到这个错误
Permission denied (publickey).fatal: Could not read from remote repository.
请确认你有正确的访问权限
]
按照这个步骤。
i. ssh -T [email protected] OR ssh -T [email protected] depending on which you are using { This will attempt to create a connection to Bitbucket OR Github Cloud ).
ii. If you do not see a message similar to (logged in as username.). Go to the next step
iii. ssh-add ~/.ssh/identity (identity is whatever name you saved the file when generating a key)
iv. You will get this message (Identity added: /path to ssh file/.ssh/mywork ([email protected])
v. You can now clone your repository.