windows 如何在第二台计算机上设置 Github SSH 密钥

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8753014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:47:58  来源:igfitidea点击:

How to setup Github SSH key on second computer

windowsgitssh

提问by Jason

I've got a Github account setup on one computer. I would like to also access my Github account on a second machine using the same SSH key I used for the first computer. How do I import the SSH private key into the new computers user profile?

我在一台计算机上设置了 Github 帐户。我还想使用我用于第一台计算机的相同 SSH 密钥在第二台计算机上访问我的 Github 帐户。如何将 SSH 私钥导入到新计算机用户配置文件中?

cp ~/other_comp_github_key ~/.ssh/github

The above command did not do the job in the git bash console on Windows.

上面的命令在 Windows 上的 git bash 控制台中没有完成这项工作。

采纳答案by sarnold

It'd be best to create a new private key if github allows you to have several associated with your account. (Sharing private keys among machines is very much like sharing passwords on multiple accounts.) But not all services allow multiple keys, so...

如果 github 允许您将多个与您的帐户相关联,最好创建一个新的私钥。(在机器之间共享私钥非常类似于在多个帐户上共享密码。)但并非所有服务都允许多个密钥,所以......

You don't specify that you copied the private portion of the key; make sure you copy the private portion.

您没有指定您复制了密钥的私有部分;确保您复制私人部分。

You don't specify that you configured the ~/.ssh/configblock to use the ~/.ssh/githubkey for the github.comhost. Make sure you add a new block to your ~/.ssh/configfile just like block on the machine you stole the key from.

您没有指定将~/.ssh/config块配置为使用主机的~/.ssh/github密钥github.com。确保在~/.ssh/config文件中添加一个新块,就像在您窃取密钥的机器上添加块一样。

host github.com
    IdentityFile ~/.ssh/github

(I don't know that the host is github.com-- if you use a different hostname, then use that.)

(我不知道主机是github.com- 如果您使用不同的主机名,则使用它。)

回答by Matt Ball

Argh! No!

啊!不!

Do. Not. Share. Private. Keys.

做。不是。分享。私人的。钥匙。

Make a newkeypair on the second computer.

在第二台计算机上制作新的密钥对。

回答by rjv

The copying of the private key will work, iff the permissionsto the ssh files copied are correct, i.e. readable for the user who uses the keys, something like 555 will do. Also, since github allows multiple ssh keys to be used with same account, you can create a new keypair and add it to your account.

私钥的复制将起作用,如果permissions复制到的 ssh 文件是正确的,即对于使用密钥的用户来说是可读的,像 555 这样的东西就可以了。此外,由于 github 允许对同一帐户使用多个 ssh 密钥,因此您可以创建一个新的密钥对并将其添加到您的帐户中。