首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加SSH-Keys后询问密码的GitLab

添加SSH-Keys后询问密码的GitLab
EN

Stack Overflow用户
提问于 2019-05-17 16:22:24
回答 1查看 260关注 0票数 0

亲爱的StackOverflow社区:

我按照这个(https://gitlab.com/help/ssh/README)指令创建了ssh-keys。我将ED25519 SSH密钥对添加到网页上的GitLab配置文件中,如果我执行ssh -T git@gitlab.com,我确实会获得消息Welcome to GitLab, @username!,到目前为止,它似乎起作用了。

但是,我希望从本地存储库通过git pushgit pull访问GitLab,而不必每次都键入密码。据我所知,SSH-key应该就是他们要做的事情,对吧?

编辑:

我的.ssh/config包含:

代码语言:javascript
复制
Host machine                                                                                                                                                                                                   
      User username                                                                                                                                                                                           
      HostName machine.webside.com

.gitconfig包含:

代码语言:javascript
复制
[user]                                                                                                                                                                                                      
        name = John Doe                                                                                                                                                                                   
        email = john.doe@email.com

.git/config包含:

代码语言:javascript
复制
[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
EN

回答 1

Stack Overflow用户

发布于 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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56182433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档