Fail to clone repository using ssh on Gitblit - ssh

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.

Related

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

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)"

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

GitKraken Unrecognized allowed types:8

I'm using GitKraken 1.8.0 on windows 10 machine to connect TFS 2015 and when I try to do (Push, Pull, Fetch) I always get toast message error says
Unrecognized allowed types:8
however, I can do these operations successfully using the CLI or Source Tree.
What is the cause of this issue!? and how to overcome that!?
First disconnected and reconnected your TFS account and try again. Also try to clear TFS cache.
Try to directly use Visual Studio with GIT when connecting TFS2015. If this also can work and since you can do the operations successfully using the CLI or Source Tree ,then the issue should related to GitKraken.
To use Gitkraken connect other remote Git repo such as the one hosted on GitHub. If you still got the same error. You may need to give a try with reinstall GitKraken.
It turned out that TFS on a different domain and connecting my computer to this domain solved the problem and everything is working fine now.
The error message doesn't say much but I guess that Unrecognized allowed types:8 error message is some sort of authentication error using the username in [domain\username] format isn't working in this case
Generate GitKraken key, the step is Preference -> Authentication, choose General tab, and press Generate new Private/Public key "Generate" button.
Copy your gitkraken_rsa.pub key by press copy icon button. (SSH Public key item)
Paste your key into TFS server.
Copy your project SSH path from TFS to your Gitkraken Remote push/pull path and be careful there is no unnecessary ".git" word behind your path, if there is, delete it.
Try to Git Fetch/Pull/Push by GitKraken!
I know this is very old thread, but in case any of the mentioned solutions doesn't work for future readers, especially if you are NOT using any kind of integrations inside GitKraken, go to Credential Manager (Windows users) and under "Windows Credentials" -> "Generic Credentials" try to find your "git:" that is causing this issue and update the password to correct one for your git credentials.

git fails on ssh communication

I recently upgraded git to 1.8.4.msysgit.0 (on Windows 7) and ever since I haven't been able to push to a repo that I've been using for years. (Note: I also downgraded to 1.7.0.2 that I used to be using for a long time but that didn't help either.)
I get this for a simple git push:
Using username "git-receive-pack 'git-myname".
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What is this strange username?
I get a similar message for a git clone as well (...git-upload-pack...). NB: I can clone via https fine.
SSH itself seems to be fine with PuTTY's plink:
C:\test>set GIT_SSH
GIT_SSH=C:\Program Files\PuTTY\plink.exe
C:\test>git remote -v
origin ssh://git-myname#free1.projectlocker.com:myrepo.git (fetch)
origin ssh://git-myname#free1.projectlocker.com:myrepo.git (push)
C:\test>"C:\Program Files\PuTTY\plink.exe" -v git-myname#free1.projectlocker.com -i mykey.ppk
Looking up host "free1.projectlocker.com"
...
Using SSH protocol version 2
...
Reading private key file ".\mykey.ppk"
Using username "git-myname".
Offered public key
...
Offer of public key accepted
...
Access granted
Opened channel for session
...
I can push to the repo via ssh from a linux box using the same key. I can also ssh to the host with OpenSSH (from Windows) but cannot set it up either so that git uses it properly.
Why does git fail?
After quite some sweat and fiddling around I found that git works provided: (a) the key is loaded into Pageant and (b) the ssh:// prefix is removed from the remote url.
(b) is the same as it was before I started fiddling around; (a), however, was never required. I may look after some way to avoid it but I'm too happy now to bother ;).