相关疑难解决方法(0)

如何使用多个ssh密钥用于具有相同主机的多个gitlab帐户

我想在Gitlab网站上使用2个帐户,每个帐户使用不同的ssh密钥

我成功生成了密钥并将它们添加到~/.ssh 我创建~/.ssh/config文件的文件夹中并使用其中一个,它的工作正常我也可以通过编辑~/.ssh/config文件在两个密钥之间进行交换

问题是:我想在同一时间使用它们,但我找到的所有教程都采用了不同的主机:/

实际上我的两个帐户都在同一个主机上

如何编辑~/.ssh/config文件以接受同一主机的两个帐户

注意: 我读过这个问题,但我无法从中获得帮助

我的两个帐户是username1username2 repo URL看起来像:git@gitlab.com:username1/test-project.git

我目前的~/.ssh/config档案:

Host gitlab.com-username1
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_rsa

Host gitlab.com-username2
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_rsa_username2
Run Code Online (Sandbox Code Playgroud)

更新1:

1)当我在~/.ssh/config文件中使用一个键时,一切都很完美(但每次我想要更改我使用的用户时更新它都很无聊)

2)当我使用这条线时, ssh -T git@gitlab.com-username1 ssh -T git@gitlab.com-username2 它的效果很好,并返回一条欢迎信息

从1)和2),我认为问题肯定来自~/.ssh/config文件,特别是Host变量

更新2:(求解) 求解是编辑.git/config从文件 [remote "origin"] url = git@gitlab.com:username1/test-project.git[remote "origin"] url = git@gitlab.com-username1:username1/test-project.git

并为此做同样的事情 username2

git ssh ssh-keys gitlab

17
推荐指数
1
解决办法
7679
查看次数

MSysGit和ssh配置.失踪

1)运行Git Bash(C:\ Program Files(x86)\ Git\bin\sh.exe --login)

$ ssh -v git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/Alexander Fedorov/.ssh/config
debug1: Applying options for github.com
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
...
Hi xpoft! You've successfully authenticated, but GitHub does not provide shell access.
...
Run Code Online (Sandbox Code Playgroud)

好的!ssh配置好读.

2)从cmd.exe运行

C:\Users\Alexander Fedorov>ssh.exe -v git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to github.com [207.97.227.239] port 22.
...
debug1: No more authentication methods to try.
Permission denied …
Run Code Online (Sandbox Code Playgroud)

windows git ssh msysgit

10
推荐指数
1
解决办法
1万
查看次数

Heroku - 添加了SSH公钥,但仍然收到Permission denied(publickey)错误

之前多次上传到Heroku,这次不知道什么是错的 - 也许是因为我正在使用公共互联网?

无论如何,所以我添加了一个新的公钥

>heroku keys:add
Found existing public key: C:/Users/Chris/.ssh/id_rsa.pub
Uploading SSH public key C:/Users/Chris/.ssh/id_rsa.pub...done

>git push heroku master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

为什么我不能推送到heroku?

我检查了我的钥匙

heroku键

我的终端正确,所以它应该工作.有人解散了吗?

git heroku

6
推荐指数
1
解决办法
3593
查看次数

标签 统计

git ×3

ssh ×2

gitlab ×1

heroku ×1

msysgit ×1

ssh-keys ×1

windows ×1