Able to authenticate with SSH with Github but somehow says "key is already in use"? - authentication

I have two ssh keys i've created, first one for my personal use and
the second one which I just created for work/school.
When I log into using git CLI using SSH with the second SSH key, it says
that i have successfully logged in like below
$ winpty gh auth login
? What account do you want to log into? GitHub.com
? You're already logged into github.com. Do you want to re-authenticate? Yes
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? C:\Users\dykim\.ssh\id_rsa.
pub
? Title for your SSH key: (GitHub CLI) second-key
? Title for your SSH key: future_proof
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: 0B1D-6370
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
HTTP 422: Validation Failed (https://api.github.com/user/keys)
key is already in use
so somehow there isn't a problem to authenticating.
But I am worried that this will somehow pop up later and be a problem later when I am
working on my future projects for work.
What can I do to avoid this issue?

That seems similar to a pending reported issue #5299: "Spurious auth error when SSH key is already registered on account"
Steps to reproduce the behavior
Run gh auth login and select an SSH key that is already registered with the account
Get the above error, even though the key will work correctly
Expected vs actual behavior
I think there are a couple of ways that the handling of already registered keys could be improved:
Given the CLI app is granted full permission over the user's registered SSH keys, it could presumably list the already registered ones first and only attempt to register a new key if it wasn't already registered.
Then the error would only occur if the key was registered on a different account (or you uploaded it via the web browser while also attempting to register the CLI app, which would be an odd thing to do)
Customise the error message when this step fails to say something like "key already in use (Note: this error is expected if this SSH key was already registered on your account)"

Related

What happens when I run "ssh git#gitlab.com

I have tried google it and check the gitlab-documentation but did not find a good answer for this.
When I setup GitLab I am advised to test my SSH-keys to my GitLab URL instance.
I use git#gitlab.com.
What actually happens when I run "ssh git#gitlab.com"
I understand how you use SSH to login to a remote device e.g. Cisco Router with SSH Admin. But in this case: who is git#gitlab.com? [username]#gitlab.com makes more sense to me.
Somehow it must find my Gitlab account (since it is there my public key is stored). How can I do that when I use a generic git#gitlab.com ?
I am after a more step-by-step answer (Client-Server)
[username]#gitlab.com makes more sense to me
It would not: that would ask to open an SSH session as 'username': that account does not exist. Only one account exists: 'git'.
Then, in ~/.ssh/authrorized_keys, your public key is found, alongside:
an ID (as shown here), matching your registered GitLab account,
a forced command, which will call a GitLab script in order to execute the Git command.
That way:
there is no interractive session possible on GitLab's server
the project gitlab-shell gets your ID and hangle your Git query
for found it, go in repository on clone, select ssh, begin start copy up to :,
now test

Logon failed, use Ctrl + C to cancel basic credential prompt

I'm facing problems while trying to pull/push my code into a GitHub repository using the cmd prompt for the last two days. How can I resolve this issue?
Logon failed, use Ctrl + C to cancel basic credential prompt. Username for 'https://github.com': satyendrasingh8 Password for 'https://satyendrasingh8#github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/satyendrasingh8/chatApp.git/'
Fitz_Hoo is right! I just wanted to give a more detailed explanation that fix my issue. Essentially GitHub deprecated their password authentication recently (you can read more by clicking here).
Now instead of adding your username/email and password, you will login with your browser. The image below is the new interface. As Fitz_hoo mentions, you must update your Git to see the new changes!
If you are using Windows, you can simply use this command below to update your Git:
git update-git-for-windows
I fixed the problem just simply by upgrading my client Git Bash to the latest version!
When I encountered the problem, I received an email from a GitHub official, who told me the reason was mainly the Git version was incompatible:
GitHub has changed how users authenticate when using Git for Windows, and now requires the use of a web browser to authenticate to GitHub. To be able to login via web browser, users need to update to the latest version of Git for Windows. You can download the latest version at:
https://gitforwindows.org/
One reason for this message could be that the remote branch you were trying to pull was already deleted.
Delete the GitHub entry from Credential Manager: Control Panel → User Accounts → Credential Manager.
Then push the code again.
For me, the problem was that instead of my username I was trying to login with my email.
I received an email from GitHub telling me
We recently updated the format of our API authentication tokens,
providing additional security benefits to all our customers. In order
to benefit from this new format, please regenerate your personal
access token
I regenerated my personal access token (PAT) and was then unable to log in from command line on Windows 10 when I tried something like git pull.
A window would pop up, inviting me to enter 'username or email' and password. I tried various combinations, using the PAT, as mentioned in the GitHub documentation, and the actual password, but every time I received:
Logon failed, use ctrl+c to cancel basic credential prompt
Thanks to the answers from Fitz_Hoo and ousecTic, I updated my Git install with the command provided by ousecTic, and the authentication process was then completely different.
You can opt to use a PAT, but when you paste it in, no characters at all are shown, so just hit Enter.
In my case, I had this issue in relation to the federated authentication to AWS CodeCommit. The fix was to upgrade git to +v2.30.z (i.e. 2.35.3) and disable interactive prompt (docs):
git config --global credential.interactive false
A global configuration in ~/.gitconfig would look like:
[credential]
interactive = false
A AWS CodeCommit specific configuration, would look like (in ~/.gitconfig):
[credential "https://git-codecommit.us-east-1.amazonaws.com"]
interactive = false
here is the solution which works for me, uninstall Git from Machine after that install new version of it and sign in via web

OpenShift (Cloud) Pod STATUS: Crash Loop Back-off,changing ownership not permitted

I created an application on existent OpenShift project by pulling a docker image from remote repo.
The pod is created but fails with STATUS "Crash Loop Back-off".
Invesitgating the reason using
oc log <pod id> -p
it appears a list of unsuccessfull "chown: changing ownership of '...': Operation not permitted
I found this is due to non predictable user id running the container.
According to
https://docs.openshift.com/container-platform/3.6/admin_guide/manage_scc.html and various post here and there,
it seems the solution is to relax security policy:
oc login -u system:admin https://<remote openshift endpoint>
oadm policy add-scc-to-group anyuid system:authenticated
If this is the solution, I don't know, because I cannot get out of 1st problem:
oc login -u system:admin
asks for login/pwd and after print an error
error: username system:admin is invalid for basic auth
I guess there is the need of a certificate, a token, something secure, but I cannot understand how to generate it from Openshift, or
if there was a key pair to generate locally (of which kind) and how to bind the key to the user. Furthermore, checking in the web console
I cannot see that kind of user (system:admin).
Am I missing something?
Thanks a lot,
Lorenzo

ERROR: (gcloud.compute.ssh) Could not fetch resource: - Insufficient Permission

I am having trouble working through the Compute Engine Quickstart: Build a to-do app with a MongoDB tutorial. (edit: I am running the tutorial from within the compute engine console; i.e. https://console.cloud.google.com/compute/instances?project=&tutorial=compute_quickstart)
I SSH into the backend instance. I enter the "gcloud compute" command as copied from the tutorial. I am prompted to enter a passphrase. The following is returned:
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in
...
<< Identifying detail ommitted >>
...
**ERROR: (gcloud.compute.ssh) Could not fetch resource:
- Insufficient Permission**
I had run through this stage of the tutorial on a previous occasion with no problems.
I am working from a Windows 10 PC with the google-cloud-sdk installed. I am using google chrome. I have tried in both regular and incognito modes.
Any help or advice greatfully received!
DaveDub
It looks like the attempt to SSH is recognising the instance in your project, but the user doesn't have the required permissions to access the machine.
Have you tried running:
gcloud auth login
and completing the web-based authorization to ensure you are attempting to access the machine as the correct (authenticated) user? This process ensures the Cloud SDK you are running inherits the permissions of the user specified in the web-based authorisation. See here for more information on this.
It's also worth adding the link to the tutorial you are following to your question.
Besides the accepted answer, be sure you are in the correct gcloud project
gcloud projects list
Then
gcloud config set project <your-project>
I just ran into this for yet another reason. Google has always had poor handling of multi-user auth conflicts with their business products. Whatever you sign into a clean chrome session with 'first' gets a 'special', invisible role. I've noticed with gsuite that I get 'forced' into that first user when I try to access the admin panel, and the only way to escape is to make sure that whatever google user I use for the gsuite admin is 'first', or open an incognito window. I've seen this bug for years, can't believe it still exists.
Anyways, I ran into a similar issue. Somehow I was the wrong google user, so the link I got when copy/pasting out of 'connect with gcloud command' was implying wrong google user. Only noticed later when I just gave up and used the terminal that I was not my normal user... So, might look into that.

Fail to clone repository using ssh on Gitblit

I've tried to clone a repository from my gitblit server using SSH, but it showed that "fatal: could not fetch refs from ssh://server-name:29418/repo-name.git"
Here is what I've done:
1. Create a user named user1 in Gitblit server, and grant it access permission to an empty reposity named test.git.
2. On my client, usging ssh-keygen to create a key pair
3. Upload my public key to the server
4. Try remote login using ssh, and it succeed.
5. Try to clone the repository, it failed and show the error message
"fatal: could not fetch refs from ssh://user1#server-name:29418/test.git".
Could anyone please tell me where I did wrong please?
It may have actually worked - check your repo-name folder.
If you are cloning an empty repository there are no refs to fetch. There is a bug in JGit (used server-side by Gitblit) which returns an incorrect result to the native git client which causes a message like what you describe to be displayed after cloning an empty repo. If JGit returned the correct result, your native git client should have said something about cloning an empty repository.