github deploy keys: how Do I authorize more than one repository for a single machine
So, I have a host, call it
rob. I used ssh-keygen on
rob to get a public key, which I gave to github in the add a new deploy key screen for repository
cheech. Now I want to deploy
rob as well. But if I go to the add new deploy key screen for repository
chong on github, and paste in the public key I generated on
rob it says
key already in use. I thought, if they key was in use, I could clone
rob but that says permission denied.
So clearly this is more complicated than I thought and it involves having multiple keys or something. What should I do to clone
Thank you for your help.
Once a key has been attached to one repo as a deploy key, it cannot be
used on another repo. If you're running into this error while setting
up deploy keys, then you'll need to modify your remote and set up your
~/.ssh/config file to use a non-existent github.com hostname that
ssh will be able to use to pick the correct ssh deploy key for your
# first we remove the origin $ git remote -v origin email@example.com:username/foo.git (fetch) origin firstname.lastname@example.org:username/foo.git (push) $ git remote rm origin # here we add a new origin using a host nickname called # foo.github.com that we will reference with a Host stanza in our # ~/.ssh/config to specify which key to use with which fake hostname. $ git remote add origin email@example.com:username/foo.git $ git remote -v origin firstname.lastname@example.org:username/foo.git (fetch) origin email@example.com:username/foo.git (push)
Generate the deploy key for your repository and name it something reasonable like:
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa-foo -C https://github.com/username/foo Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/username/.ssh/id_rsa-foo. Your public key has been saved in /home/username/.ssh/id_rsa-foo.pub. The key fingerprint is: c0:ff:ee:34:24:11:5e:6d:7c:4c:b1:a0:de:ad:be:ef https://github.com/username/foo The key's randomart image is: +--[ RSA 2048]----+ | E o..o.oo. | | M o o o .+CoW | | + o = o. .. | | . . + | | S | | o . | | + | | . o | | ..o. | +-----------------+
added the deploy key
you will then need to add the following stanza to your
Host fake-hostname-foo.github.com Hostname github.com IdentityFile ~/.ssh/id_rsa-foo
Now you can test it with:
$ ssh -T firstname.lastname@example.org Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Managing deploy keys, SSH agent forwarding; HTTPS with OAuth tokens; Deploy keys; Machine users Multiple tokens (one for each user) are not needed; one token per server is using a deploy key, which is an SSH key that grants access to a single repository. 65 github deploy keys: how Do I authorize more than one repository for a single machine Oct 3 '12 63 Should I be concerned about excess, non-running, Docker containers? Feb 20 '14
The simplest solution I found was outlined here.
1) Enter this command(You'll do this for however many keys you need):
ssh-keygen -t rsa -C "email@example.com"
2) When prompted with the the statement below type in a unique name(i.e.,foo1_rsa).The file will be created in your current directory and you may need to move it to .ssh if you want to be tidy:
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
3) Update your SSH config file:
Which may be empty:
Host cheech github.com Hostname github.com IdentityFile ~/.ssh/foo1_rsa Host chong github.com Hostname github.com IdentityFile ~/.ssh/foo2_rsa
Using multiple GitHub deploy keys on a single server with a single , Using multiple GitHub deploy keys on a single server with a single user These repository level SSH keys are known in GitHub as deploy keys. Host github.com HostName github.com IdentityFile ~/.ssh/repo-1-deploy-key /11656134/github-deploy-keys-how-do-i-authorize-more-than-one-repository-for-a-single-mac. The SSH key apparently matches the key with ID 1 first, thus, Gitea checks this ID. Since the key does not exist (and is therefore not authorized to access the repository), the client is denied access. (The key is by the way just once in the database). #1870 should fix such issues and also implements a superior alternative to the authorized_keys file. But as the people mentioned in there, it might break compatibility for some people.
A deploy key for github is unique ... You have to generate a new key for the other repository. Just run ssh-keygen again
See the github documentation for this: https://help.github.com/articles/managing-deploy-keys
Authorizing an SSH key for use with SAML single sign-on, To use an SSH key with an organization that uses SAML single sign-on (SSO), Changing two-factor authentication delivery methods for your mobile device You can authorize an existing SSH key, or create a new SSH key and then authorize it. For more information about creating a new SSH key, see "Generating a new Simple automated GIT Deployment using GIT Hooks. Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial. How it works. You are developing in a working-copy on your local machine, lets say on the master branch.
If you're comfortable giving
rob access to all of the private repositories in your GitHub account, you could remove the key as a deploy key from
cheech and then add it as an SSH key to your GitHub account as a whole. This would give
rob access to both
This won't work if you have other repositories in your account that you do not wish
rob to access.
If you need finer-grained control, you will need to generate additional keys on
rob and assign them as deploy keys to specific repositories.
How to configure multiple deploy keys for different private github , How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent. Let's say alice is a github.com user, =head1 NAME git-deploy - automate the git steps required for a deploying code from a git repository =head1 SYNOPSIS git deploy [deploy-options] [action [prefix]] [action-options] git deploy --man actions: status # show rollout status of current repository start|abort|sync|finish # normal multi-server rollout sequence (finish is automatic if sync succeeds) start|abort|release # normal single
While Pimkin's idea was great, I didn't want to install
node just for this, so I created something similar in
Install and use:
curl https://gist.githubusercontent.com/blvz/8eeebacae11011c25fc79eff12f49ae9/raw/6f2f7f3709a0fe852d8a3a5bb125325e3ffbc7d8/gh-deploy-clone.sh > /usr/local/bin/gh-deploy-clone chmod +x /usr/local/bin/gh-deploy-clone gh-deploy-clone user/repo # You can also give it a name, in case # you have multiple deploy targets: gh-deploy-clone user/repo staging
github deploy keys: how Do I authorize more than one - html, github deploy keys: how Do I authorize more than one repository for a single machine - github. If either of these environment variables is set then 'git fetch' and 'git push' will use the specified command instead of 'ssh' when they need to connect to a remote system. The command will be given exactly two or four arguments: the 'port' from the URL when it specifies something other than the default SSH port.
Managing multiple GitHub Deploy Keys on a single server, However, each repo must have its own unique key. If you're deploying multiple GitHub repos on a single machine, that means you'll need to set Under your repository name, click Upload files . Drag and drop the file or folder you'd like to upload to your repository onto the file tree. At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file. You can attribute the commit to more than one author in the commit message. For more
Allow Deploy keys to push to protected branches once more , Today, we don't treat a deploy key as a machine user, but we evaluate the After this change, all of the users have to manually add a deploy key to the they push back tags and version changes back to the repo using a deploy key. git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git GitHub brings together the world’s largest community of developers to discover, share, and build better software. From open source projects to private team repositories, we’re your all-in-one platform for collaborative development.
Authentication & Authorisation, root@remote $ adduser deploy root@remote $ passwd -l deploy From our servers to the repository host. Hint: If you have more than one developer in your team, they should all add their public key to the simply curl / wget each user's key into the authorized keys file on the server directly from Github. And if get_group() isn't the right method to do "many-grp-to-one-df", we need either a more advanced get_groups(), or a method with a different name, to satisfy this need. Yes we can do pd.concat([grouped.get_group(name) for name in groups]) , but we can also do something more elegant and powerful.