Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use the same ssh private/public key pair on 2 machines to access a git repository?

I've recently setup an inhouse git repository server and have it up and running with gitosis installed as the management tool. Read only access is available via the git:// protocol and write access is available via gitosis using ssh public keys.

I have a developer that has been granted access to his projects with a public key that was generated on his desktop workstation.

He is now wanting to access that repository from his laptop using the same ssh key pair. He's copied has .ssh folder in it's entirety to his laptop and has tried to clone from the repository without success.

Is this a valid thing to try?

Does a ssh key pair need to be generated per machine? This seems weird as it would effectively require a per machine username to be added to the gitosis configuration.

Any help would be appreciated.

like image 568
Lou Avatar asked Jul 22 '09 01:07

Lou


People also ask

Can two machines use same SSH key?

The same SSH key should be able to be used from multiple clients. I have different SSH keys for different networks and they're actually stored on an encrypted USB drive that I use from several different computers without a problem.

Can I use the same public key on multiple computers?

There are no issues about connecting with the same key as your desktop. I would set up an ssh agent for your key on the laptop, and forward the agent to the desktop, so you'll be using that key on other systems you access from there.

Can I use the same SSH key on two 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 you use the same SSH key on multiple GitHub accounts?

GitHub does not allow us to use the same SSH key in multiple accounts, so we'll have to create separate keys for each account. We can create SSH keys and add them to our SSH agent by following this guide from the GitHub Documentation.


2 Answers

Yes I think you can.

I have something similar. Two machines, one Intel (desktop) the other one Sparc. I can log into both machines and access the same CVS server (another machine) using SSH access with the same key pair which was generated on the Intel machine.

Make sure when you copy across your private key that you set both the permissions of the .ssh directory correctly (0700) and your home directory cannot be group or world writable. The id_rsa should only have user read access (0400)

like image 178
hookenz Avatar answered Sep 21 '22 05:09

hookenz


Yes, that's perfectly legitimate. ssh keys don't care where they were generated, and it's fine to have them on multiple machines at once.

Try giving the ssh client the "-v" or "-vv" option (for verbose output) and check the server's ssh log to debug the problem.

like image 41
nobody Avatar answered Sep 22 '22 05:09

nobody