Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

GitHub use a single SSH key for all repositories

David Carr

Development

When using SSH with GitHub you'll often need to add deploy keys to the repo to allow read and write access over SSH. This can be problematic when using multiple repositories as Github won't allow the same deploy key (ssh key) to be used on multiple repositories. 

There are a few options at this point:

  • Move the deploy key from one repo to another
  • Setup multiple keys one per project
  • Set a key on your account that will work for all your repositories 

I opt the setting a key on my account. This way every repository I have in my account will allow the SSH connection, this is how the GitHub desktop clients works too.

Setup:

1) open terminal and generate a new id_rsa key (if you've already got a key this step can be skipped).

ssh-keygen

The output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):

Press enter to accept the default path

Enter passphrase (empty for no passphrase):

Press enter to accept no password or enter a password first.

The response will look something like:

The key's randomart image is:
+--[ RSA 2048]----+
|        .. .  .oB|
|       . .. + .++|
|        . o. o...|
|         o   .   |
|        S   .. . |
|           o. o  |
|          o..+   |
|          ....o  |
|           oE.   |
+-----------------+

Get the key:

Go to .ssh folder

cd ~/.ssh

Next open rd_rsa in vim:

vi id_rsa

Copy the key be careful not to copy any whitespace

Exit vim by pressing: followed by wq 

Add key to your GitHub account

Go to your account settings and click on 'SSH and GPG keys https://github.com/settings/keys

Click on New SSH Key

Give the key a name I put my laptop name here followed by the key you copied (id_rsa) click Add SSH Key.

Done now whenever you perform an action over SSH on the machine the connection will be authorised.

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.