J. *_*Doe 0 ssh-keys gitlab ubuntu-18.04
亲爱的 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 密钥,这应该正是他们所做的,对吧?
编辑:
我的.ssh/config包含:
Host machine
User username
HostName machine.webside.com
Run Code Online (Sandbox Code Playgroud)
其中.gitconfig包含:
[user]
name = John Doe
email = john.doe@email.com
Run Code Online (Sandbox Code Playgroud)
并且.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
Run Code Online (Sandbox Code Playgroud)
您的.git/config显示您的存储库是通过 HTTPS 访问的,因此使用用户名和密码身份验证。
如果您想切换到 ssh,除了添加 SSH 密钥之外,还必须更改本地 GIT 配置。
GitHub 有一个非常详细的教程,介绍如何将 GIT 远程 URL 从 HTTPS 更改为 SSH: https://help.github.com/en/articles/chang-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.
| 归档时间: |
|
| 查看次数: |
2137 次 |
| 最近记录: |