亲爱的StackOverflow社区:
我按照这个(https://gitlab.com/help/ssh/README)指令创建了ssh-keys。我将ED25519 SSH密钥对添加到网页上的GitLab配置文件中,如果我执行ssh -T git@gitlab.com,我确实会获得消息Welcome to GitLab, @username!,到目前为止,它似乎起作用了。
但是,我希望从本地存储库通过git push和git pull访问GitLab,而不必每次都键入密码。据我所知,SSH-key应该就是他们要做的事情,对吧?
编辑:
我的.ssh/config包含:
Host machine
User username
HostName machine.webside.com.gitconfig包含:
[user]
name = John Doe
email = john.doe@email.com.git/config包含:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://gitlab.com/johndoe/projectname.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "branch1"]
remote = origin
merge = refs/heads/branch1
[branch "branch2"]
remote = origin
merge = refs/heads/branch2发布于 2019-05-20 16:10:56
您的.git/config显示您的存储库是通过HTTPS访问的,因此使用用户名和密码身份验证。
如果想要切换到ssh,除了添加SSH密钥之外,还必须更改本地GIT配置。
关于如何将GIT远程URL从HTTPS更改为SSH,GitHub有一个非常详细的教程:https://help.github.com/en/articles/changing-a-remotes-url#switching-remote-urls-from-https-to-ssh
这里描述的步骤也适用于GitLab,只是您的远程URL将类似于git@gitlab.com:<repo-url.git>而不是git@github.com:<repo-url>.git
或多或少,你只需要使用git remote set-url origin。
https://stackoverflow.com/questions/56182433
复制相似问题