GitLab设置ssh密钥

在将git global配置为:

后,我从我参与的项目中克隆了一个空项目目录。
$ git config --global user.name "My username"
$ git config --global user.email "myeamil.com"

$ git clone git@gitlab.com:our-projects/this-project.git
$ cd this-project
$ touch README.md
$ git add README.md
$ git commit -m "add README"

然后按照here描述的步骤生成并添加一个ssh key(我实际上创建了一个ED25519 SSH keys)。但是,确保正确添加ssh的测试失败。

$ ssh -T git@our-projects/this-project.git
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known

$ ssh -T git@our-projects
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known

$ ssh -T git@this-project.git
ssh: Could not resolve hostname gitlab.com:it-porto/transportation-mode-detection.git: Name or service not known

我的ssh密钥目录的内容:

$ ls /home/user/.ssh/
id_ed25519  id_ed25519.pub  id_rsa  id_rsa.pub  known_hosts  known_hosts.old

我该如何解决?

编辑

我按照注释中的建议进行了ssh -T git@gitlab.com的操作,显示了欢迎消息,但这似乎不起作用,我无法git push到遥控器。

$ssh -T git@gitlab.com
Welcome to GitLab,@user!

$git push origin master
Counting objects: 8,done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6),done.
Writing objects: 100% (8/8),45.49 KiB | 3.50 MiB/s,done.
Total 8 (delta 0),reused 0 (delta 0)
remote: GitLab: 
remote: A default branch (e.g. master) does not yet exist for our-projects/this-project
remote: Ask a project Owner or Maintainer to create a default branch:
remote: 
remote:   https://gitlab.com/our-projects/this-project/-/project_members
remote: 
To gitlab.com:our-project/tthis-project.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:our-projects/this-project.git'


$ git remote -v
origin  git@gitlab.com:our-projects/this-projectt.git (fetch)
origin  git@gitlab.com:our-projects/this-projectt.git (push)
magss 回答:GitLab设置ssh密钥

你很好走

Read the content of file by  cat id_rsa.pub 

并从终端复制内容 打开您的gitlab UI 从左上角点击用户,然后进行设置。

转到ssh并将以上内容粘贴到框中 enter image description here

本文链接:https://www.f2er.com/3160211.html

大家都在问