I am trying to clone private repository using Python. I am using Git Python package to clone the repository but I am getting an error:
Error :
GitCommandError: 'git clone -v https://github.mit.edu/mitx/content-mit-1690rgit edxcourse' returned exit status 128: Cloning into 'edxcourse'...
remote Repository not found.
fatal : Authentication failed for 'https://github.mit.edu/mitx/content-mit-1690.r.git/'
However I am a member of this repository and I have access to the repository.
In your case, gitpython merely returns an error it received from the git executable it envoked.
If you call git clone -v https://github.mit.edu/mitx/content-mit-1690rgit on the commandline, you will receive a similar error, indicating something might be wrong with your URL. Possibly it is the rgit extension, which might be a typo.
Maybe one of the devs can confirm this as I have only been playing around with Git-Python for the last few hours.
When cloning over http(s) it seems to rely on the .netrc file rather than asking for auth like the Git CLI client would.
cat > ${HOME}/.netrc < EOF
machine github.mit.edu
login <username>
password <password>
EOF
chmod 600 ${HOME}/.netrc
If you're on Windows, that works via Cygwin too.
The repository which I was trying to Clone is a secured repo. So I need to establish a secure ssh authentication connection. and then it worked for me.
Related
I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.
I got a problem. A am trying to learn git. I initialized my local repo, added everything, committed. I'm using atom cmd and bash, because there are some commands, that are unavailable in atom cmd. I created an ssh-key, added it and everything works fine. I am trying to synchronize everything and pull from the remote repo, but I am getting an error:
PS C:\Users\keldranase\Documents\Obsidian Vaults> git pull origin master --allow-unrelated-histories
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
At the same time, when I am doing same using bash, everything works fine:
keldranase#DESKTOP-SH6U8NC MINGW64 /c/users/keldranase/documents/Obsidian Vaults (master)
$ git pull origin master --allow-unrelated-histories
Whats the reason behind this? How to solve this problem? What am I doing wrong? Your help would be appreciated.
Screenshot:
Your SSH key is not loaded. You need first to start the ssh client and then add the ssh key, you can find more information here. And here you can find some useful troubleshooting information for your error and other issues you might experience with SSH - Error Permission Denied.
I'm on a Windows 10 machine and I have both Git Bash and Ubuntu for Windows Subsystem for Linux (WSL) installed. When I use GitHub's official desktop app to clone a repo via HTTPS everything works fine and I can push my commits via Visual Studio Code with no problems whatsoever. I then try to clone a repo via SSH with Hyper (WSL Bash) and get this:
The authenticity of host 'domain.com (a.b.c.d)' can't be established.
RSA key fingerprint is XX:XX:...:XX.
Are you sure you want to continue connecting (yes/no)?
After answering yes and openning that repo in VS Code and try to push my new changes to GitHub, I get this error:
Git: Host key verification failed.
And this is what I get as Git Log in Output:
Host key verification failed.
fatal: Could not read from remote repository.
I have set up my SSH key on WSL using this method and I didn't set up any passphrase. I tried this on my brother's PC which is exactly set up like mine and it worked just fine. I would appreciate any help!
UPDATE: I typed ssh -T git#github.com in Hyper and got this as an answer: You've successfully authenticated, but GitHub does not provide shell access.
P.S. I'm a newbie in programming and stackoverflow, so please be concise and give me step by step instructions. The more you use technical terms, the more I'll probably get lost!
Try first, for that new push, to do it in command line:
cd c:\path\to\local\repo
git status
git log
git remote -v
git push -u origin master
Make sure that:
git status is clean (no pending changes)
git log shows you at least one commit
git remote -v shows you as origin the URL of your remote GitHub repository
(as an SSH URL git#github.com:<you>/<yourRepo>)
Then push, and go back to VSCode.
Should be faster than the other solution:
In vscode open a new terminal of type "Command Prompt"
Run: git push and accept the new key when prompted.
This will store the remote key for future use.
I am trying to add repository via Xcode > Settings > Accounts and I am stuck on the proper address. Address of our repo is quite simple: my.domain.com:port/project-name. Authentication via SSH Keys. Could someone help me to understand what's going on here? See screenshot below.
By the way running git clone git+ssh://git#my.domain.com:port/project-name works fine.
EDIT
Running git clone without git+ssh//
git clone git#my.domain.cz:2222/project-name
or
git clone git#my.domain.cz:22/project-name
is giving me same error:
ssh: connect to host my.domain.cz port 22: Connection refused
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
Xcode accepts just ssh://git#my.domain.cz:2222/project-name.
The git protocol is somehow redundant in this case. Raw git tools don't have a problem with it, but Xcode does not like it for some reason.
It always fails for me when I use existing ssh keys.
I created a new ssh key pair through Xcode and uploaded the public key to the git server (in my case, Phabricator), and it works.
I have installed SCM-Manager. I would like to use it in the future for version control. The problem is, I cannot add it as a repository in Xcode, and I cannot clone it from command line:
$ git clone http://127.0.0.1:8080/scm/git/MyRepo
Cloning into 'MyRepo'...
Checking connectivity... done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$
In Xcode I get this message:
fatal: unable to access 'http://127.0.0.1:8080/scm/git/MyRepo/': The requested URL returned error: 403
SCM server logs this
failed to read basic auth credentials
I have tried to install on different server, checkout with different user, nothing helped.
The first message means that you have cloned an empty repository. The message is only a warning and the repository is fully functional. A better way is to create the "bare" repository in SCM-Manager and add the remote reference to a local created repository:
git init MyRepo
git-remote add origin http://127.0.0.1:8080/scm/git/MyRepo/
The messages from Xcode sounds like missing credentials.