为GibHub设置ssh密钥 [英] Setting up ssh keys for GibHub

查看:139
本文介绍了为GibHub设置ssh密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循这些说明了解如何设置SSH密钥用于GibHub。

I'm following these instructions for how to set up SSH keys for use with GibHub.

这些指令指示您删除当前的 .ssh 目录并在该目录中创建新的密钥.ssh目录。我无法做到这一点,因为我的 id_dsa.pub 中已经有了我需要用于其他服务器的密钥。

The instructions tell you to delete your current .ssh directory and create new keys in that .ssh directory. I'm unable to do this as I already have keys in my id_dsa.pub that I need to use for other servers.

是否可以为GitHub设置ssh,同时保留已保存在 .ssh 中的密钥?或者有什么其他的方式来为GitHub设置ssh?

Is it possible to set up ssh for GitHub while preserving the keys I already have saved in .ssh? Or is there any other way to set up ssh for GitHub?

推荐答案

您可以重新使用您的密钥对目录,或者专门为github的使用创建一个新的密钥对。如果您决定不使用默认对,您需要修改〜/ .ssh / config 文件并为Github添加一个主机定义,将其指向新密钥文件。所以,如果你的新密钥对是 github_rsa github_rsa.pub ,把这些行放在 /.ssh/config

You can either re-use your key pair already in your directory, or create a new key-pair specifically for github's use. If you decide not to use the default pair, you'll need to modify your ~/.ssh/config file and add a host definition for Github pointing it to the new key file. So, if your new key pair is github_rsa and github_rsa.pub, put these lines in /.ssh/config:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_rsa

现在,无论何时将操作拉到 git@github.com ,将使用替代身份文件。

Now, whenever you do pull or push operations to git@github.com, the alternate identity file will be used.

这篇关于为GibHub设置ssh密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆