简体   繁体   English

几个SSH密钥和用户帐户

[英]Several SSH keys and user accounts

I have two user accounts in Gitlab. 我在Gitlab中有两个用户帐户。 One with axmug user and the other one with GbFlow . 一个使用axmug用户,另一个使用GbFlow
When I log in using axmug user there is any key in the profile settings. 当我使用axmug用户登录时,配置文件设置中没有任何键。
But when I log in using GbFlow user I created an SSH key file and I can watch it in the profile settings. 但是,当我使用GbFlow用户登录时,我创建了一个SSH密钥文件,并且可以在配置文件设置中查看它。
I use Git Bash on Windows 7 and when I type cd /Users/Invitado/.ssh and ls , I can watch three files: id_rsa , id_rsa.pub and known_hosts . 我在Windows 7上使用Git Bash,当我输入cd /Users/Invitado/.sshls ,我可以观看三个文件: id_rsaid_rsa.pubknown_hosts
This key was generated using axmug user. 该密钥是使用axmug用户生成的。 Both users have different emails. 两个用户都有不同的电子邮件。

What I want to do is upload an Android project using GbFlow user. 我想要做的是使用GbFlow用户上传一个Android项目。 When I tried, I typed the following in Git Bash command line: 尝试时,我在Git Bash命令行中键入了以下内容:

git init
git remote add origin git@gitlab.com:GbFlow/GlobalFlow.git
git add .                                                           
git commit
git push -u origin master

Everything worked except the last line: git push -u origin master . 除最后一行外,其他所有东西都起作用: git push -u origin master At this point I displayed the error: 此时,我显示了错误:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I have the keys created. 我已经创建了密钥。 What I am doing wrong? 我做错了什么?

Invitado means those ssh keys are created with the Guest account. Invitado表示这些ssh密钥是使用Guest帐户创建的。

If you are not logged on as a Guest , but with your actual account, ssh will look for those keys in %HOME%\\.ssh , with HOME set by default to %USERPROFILE% . 如果您不是以Guest身份登录的,而是使用您的实际帐户登录的,则ssh将在%HOME%\\.ssh查找这些键,默认情况下, HOME设置为%USERPROFILE%
Type set us to see the value of USERPROFILE . 键入set us以查看USERPROFILE的值。

This key was generated using axmug user. 该密钥是使用axmug用户生成的。

It does not matter with which local Windows account those keys were created. 这些密钥是使用哪个本地 Windows帐户创建的。 What matters is where the public id_rsa.pub was copied to: in which GitLab account. 重要的是公众id_rsa.pub被复制到:在GitLab帐户。 See " How to create your SSH Keys " 请参阅“ 如何创建SSH密钥

That would be the first reason why GitLab does not authenticate you properly: move those keys in your own %USERPROFILE%\\.ssh to benefit from GbFLow identity (Assuming GbFlow profile has the public key in his/her settings). 这就是GitLab无法正确验证您身份的第一个原因:将这些密钥移到您自己的%USERPROFILE%\\.ssh以从GbFLow身份中受益(假设GbFlow配置文件在其设置中具有公钥)。
Type ssh -T git@gitlab.com to confirm you are seen as GgFlow . 键入ssh -T git@gitlab.com确认您被视为GgFlow


If, from the same local Windows account ( Invitado or otherwise) you need to manage two different GitLab remote accounts, then see Working with non-default SSH key pair paths , and use a %USERPROFILE%\\.ssh\\config file. 如果从同一本地Windows帐户( Invitado或其他方式)需要管理两个不同的GitLab远程帐户,请参阅使用非默认SSH密钥对路径 ,并使用%USERPROFILE%\\.ssh\\config文件。

# GbFlow
Host gbflow
Hostname gitlab.com
RSAAuthentication yes
User git
IdentityFile ~/.ssh/gbflow_rsa

# axmug
Host axmug
Hostname gitlab.com
RSAAuthentication yes
User git
IdentityFile ~/.ssh/axmug_rsa

Then use the ssh url bgflow:<user>/<repo.git> or axmug:<user>/<repo.git> 然后使用ssh url bgflow:<user>/<repo.git>axmug:<user>/<repo.git>

This assume you have created two different sets of ssh pairs keys. 假设您已经创建了两组不同的ssh对密钥。

For gbflow (renaming the existing id_rsa / id_rsa.pub files): 对于gbflow (重新命名现有的id_rsa / id_rsa.pub文件):

~/.ssh/gbflow_rsa
~/.ssh/gbflow_rsa.pub

For axmug (with ssh-keygen -t rsa -P "" -C "axmug GitLab access" -q -f ~/.ssh/axmug_rsa ): 对于axmug (使用ssh-keygen -t rsa -P "" -C "axmug GitLab access" -q -f ~/.ssh/axmug_rsa ):

~/.ssh/axmug_rsa
~/.ssh/axmug_rsa.pub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM