Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git + assembla + multiple ssh keys/multiple computers

Tags:

git

ssh

assembla

I have multiple computers working on the same project, and I'm using a free assembla git repo account to manage all this.

In order to access the git repo, I need to generate unique SSH keys on each computer. However, a computer might be working on other assembla projects as well, so there seems to be a conflict whenever I generate a new ssh key (like I have to keep replacing the id_rsa files). Once I recreate the id_rsa files (and replace them) on a local machine, it loses access to the previous assembla git projects using the previously-generated ssh key.

I'm fairly new to the whole git business, and trying to learn as I go.

I found something that sounded like a solution to my problem: "Different SSH keys for different projects" http://www.assembla.com/spaces/breakoutdocs/wiki/Different_SSH_keys_for_different_projects

However, I don't understand how to do #1? It says to "place somewhere in $PATH this script (let its name will be gitssh)", but I don't know what/where "$PATH" is?

Any help would be greatly appreciated. Thanks!!

like image 437
Jay Avatar asked Nov 17 '11 16:11

Jay


People also ask

Can you use the same SSH key on multiple computers GitHub?

The copying of the private key will work, iff the permissions to 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.

Can Git have multiple SSH keys?

For instance, you can run an Organization's GitHub account and another one for your personal projects all on the same computer. In this article, you will learn how to use multiple SSH keys for different GitHub accounts. While working with two different GitHub accounts, you must set them up using an SSH key.


1 Answers

You can create as many public/private ssh key as you want.
Simply don't use the default names id_rsa and id_rsa.pub.

However, not using the default naming convention means ssh, by default, won't find your keys.
You need to define in your ~/.ssh directory a config file, where you will indicate what private key to use:

Host myproject1
    HostName server1
    IdentityFile ~/.ssh/project1.rsa
    User username

You can then push to myproject1 if you have added myproject1 as a remote.
See also "Unable to Git-push master to Github" for ssh troubleshooting, and "Specify an SSH key for git push without using ~/.ssh/config" for adding your ssh address as a remote.

You can add to the ~/.ssh/config file as many address as you need, each one referring a private key that you can name as you want.

like image 111
VonC Avatar answered Oct 22 '22 00:10

VonC