Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 无法使用SSH从远程存储库读取_Git_Ssh_Gitlab - Fatal编程技术网

Git 无法使用SSH从远程存储库读取

Git 无法使用SSH从远程存储库读取,git,ssh,gitlab,Git,Ssh,Gitlab,我完成了所有步骤,无法连接到远程存储库 我已将ssh密钥添加到GitLab帐户,但出现错误: user@gitlab.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 全输出: user@DESKTOP MINGW64 ~/

我完成了所有步骤,无法连接到远程存储库

我已将ssh密钥添加到GitLab帐户,但出现错误:

user@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
全输出:

user@DESKTOP MINGW64 ~/Desktop/instabot (master)
$ ssh-keygen -t rsa -b 4096 -C "email@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/user/.ssh/id_rsa):
Created directory '/c/Users/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/user/.ssh/id_rsa
Your public key has been saved in /c/Users/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:xxxx email@gmail.com
The key's randomart image is:
+---[RSA 4096]----+
...
+----[SHA256]-----+

user@DESKTOP MINGW64 ~/Desktop/instabot (master)
$ git push origin master
The authenticity of host 'gitlab.com (...)' can't be established.
ECDSA key fingerprint is SHA256:....
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitlab.com,...' (ECDSA) to the list of known hosts.
user@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

user@DESKTOP MINGW64 ~/Desktop/instabot (master)
$ git remote get-url
usage: git remote get-url [--push] [--all] <name>

    --push                query push URLs rather than fetch URLs
    --all                 return all URLs


user@DESKTOP MINGW64 ~/Desktop/instabot (master)
$ git remote get-url origin
ssh://gitlab.com/myaccount/instabot.git

user@DESKTOP MINGW64 ~/Desktop/instabot (master)
$ eval `ssh-agent -s`
Agent pid 1189
user@DESKTOPMINGW64~/Desktop/instabot(主版)
$ssh keygen-t rsa-b4096-C“email@gmail.com"
生成公共/私有rsa密钥对。
输入保存密钥的文件(/c/Users/user/.ssh/id\u rsa):
已创建目录'/c/Users/user/.ssh'。
输入密码短语(无密码短语为空):
再次输入相同的密码短语:
您的标识已保存在/c/Users/user/.ssh/id\u rsa中
您的公钥已保存在/c/Users/user/.ssh/id_rsa.pub中
关键指纹是:
SHA256:xxxxemail@gmail.com
密钥的随机艺术图像为:
+---[RSA 4096]----+
...
+----[SHA256]-----+
user@DESKTOPMINGW64~/Desktop/instabot(主版)
$git推送原始主机
无法确定主机“gitlab.com(…)”的真实性。
ECDSA密钥指纹为SHA256:。。。。
是否确实要继续连接(是/否/[fingerprint])?对
警告:已将“gitlab.com…”(ECDSA)永久添加到已知主机列表中。
user@gitlab.com:权限被拒绝(公钥)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。
user@DESKTOPMINGW64~/Desktop/instabot(主版)
$git远程获取url
用法:git远程获取url[--push][--all]
--推送查询推送URL而不是获取URL
--全部返回所有URL
user@DESKTOPMINGW64~/Desktop/instabot(主版)
$git远程获取url来源
ssh://gitlab.com/myaccount/instabot.git
user@DESKTOPMINGW64~/Desktop/instabot(主版)
$eval`ssh代理-s`
代理pid 1189
尝试将SSH URL更改为:

cd /path/to/repo
git remote set-url origin git@gitlab.com:myaccount/instabot.git

请注意,SSH用户应该始终是“
git@
”,而不是“user@

谢谢,如果在此之前添加SSH://就可以了git@gitlab.com@Tooioi是的,很抱歉那是个打字错误:
git@gitlab.com:myaccount/instabot.git
ssh://git@gitlab.com/myaccount/instabot.git
。注意一种情况下的“:”另一种情况下的“/”。
cd /path/to/repo
git remote set-url origin git@gitlab.com:myaccount/instabot.git