From e7b559b62d7fde31ad59c55f537ae29f56afc19f Mon Sep 17 00:00:00 2001 From: tekkub Date: Tue, 19 Jan 2010 16:26:37 -0700 Subject: Adding in some more guides --- _posts/2010-01-19-multiple-keys.markdown | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 _posts/2010-01-19-multiple-keys.markdown (limited to '_posts/2010-01-19-multiple-keys.markdown') diff --git a/_posts/2010-01-19-multiple-keys.markdown b/_posts/2010-01-19-multiple-keys.markdown new file mode 100644 index 0000000..52c5c6e --- /dev/null +++ b/_posts/2010-01-19-multiple-keys.markdown @@ -0,0 +1,37 @@ +--- +layout: default +title: Multiple SSH keys +description: How to push using different SSH keys on the same computer +categories: other +--- + +This guide assumes you have already created two keypairs and attached them to different GitHub user accounts. For this example we will be using `~/.ssh/id_rsa` attached to the user `joe` and `~/.ssh/id_rsa_client` attached to the user `client`. + +Adding your keys to SSH +======================= + +The first keypair, `~/.ssh/id_rsa`, uses a default name, so we don't need to do anything special to make SSH use this pair. The second pair, however, is not a default name. Therefore, we need to tell ssh about it so that it can use it: + +
ssh-add ~/.ssh/id_rsa_client
+ +If the keypair has a passphrase on it (it should!), `ssh-add` will ask you to enter the passphrase. After you have done this, the key will be available from ssh-agent so you won't have to re-enter the passphrase every time you use it. + +Configuring SSH +=============== + +Once SSH has access to both keys, you need to tell it which key to use for which server. In most cases you can assume that SSH will fall back to `~/.ssh/id_rsa` by default, but we're going to force it anyway. To begin, open `~/.ssh/config` in your favorite editor. + + + +In short what this does is tells SSH to use the client key when connecting to the server github-client, which is really github.com. + +Using the second key +==================== + +From here on, everything is the same as everyday use except for one component, the domain name. When working on a repo owned by the primary account, we would use a command like: + +
git clone git@github.com:joe/my_repo.git
+ +When we want to use the second account's key, however, we need to change the domain name. Doing so will use the settings in `~/.ssh/config` to override the defaults. + +
git clone git@github-client:client/his_repo.git
-- cgit v1.3.1