I have set up and configured git on my computer, copied the public key to the server.
My problem is that if I try to clone, push, etc using command line commands I get rejected: Permission denined (publickey).
In the meanwhile if I do the same using Git Repositories view in Eclipse, everything works against the same repository.
My understanding was that git command line and Eclipse Git uses the same configuration.
Anybody has suggestion why I get rejected from command line?
Thanks
Related
Today, I am following this video https://www.youtube.com/watch?v=RGOj5yH7evk to learn how to use GitHub, but I am using Windows.
I've set it all successfully by also following the official instruction (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh) and it works on Git Bash.
enter image description here
But I failed when I tried to "git clone" in Visual Studio Code and got this response:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I've also tried setting the config because the video mentioned config (although the official instructions does't mention this, which means Windows users don't need to care about this. But this was what I tried to solve the problem, just in case this could make influence on my problem)
file:C:/Users/CC2022/.gitconfig user.name=CC
file:C:/Users/CC2022/.gitconfig user.email=username#email.com
file:C:/Users/CC2022/.gitconfig core.editor='C:\Users\CC2022\AppData\Local\Programs\Microsoft VS Code/Code.exe' -multiInst -notabbar -nosession -noPlugin
So, is there any requirement for the folder I select to open in VS code to do the git stuff or where is the problem?
Thank you for your help
I can git clone by the HTTP link on both VS code and GitBash, or git clone by the SSH link on Git Bash.
But I have a problem (git clone by SSH link) on VS Code.
In addition, although git clone by HTTP link on VS Code is okay, but I cannot "push" edited files back to GitHub, because the access is denied
That means the repository you are trying to push back to is not one you own/have created. You might therefore have no right to contribute back to it directly.
The message keeps saying uploading files "forever". What I did was created a folder with a file inside. On Github, the repository was created successfully but the file is not uploading. And yes I have installed git.
The repository created successfully but the files are not uploading.
If you have the latest Git for Windows, chances are you have a git config credential.helper set to manager-core.
As I mentioned in "After $git push -u origin main command, Git bash is not requesting any authentication literally does nothing", the same issue is seen in command-line, not just VSCode.
This is because of the Git-Credential-Manager-Core (interface to the Windows Credential Manager, in charge of caching your credentials: GitHub username/token).
Try and install the last GCM-Core (released yesterday), and see if the issue persists then.
Or, alternatively, you could use an SSH URL, again, to see if the issue persists.
What fixed it for me:
In VSCode: File -> Preferences -> Settings.
Filter for "git".
Select "git (80)" on the left pane.
Uncheck this:
Git: Require Git User Config
Controls whether to require explicit Git user configuration or allow Git to guess if missing
I have created a repository on Github. I am using Windows 7 64 bit and Pycharm Community edition. I want to integrate the Github repository with pycharm but I am getting the error
Couldn't get the list of GitHub repositories
Connect to api.github.com:443 [api.github.com/192.30.252.127] failed: connect timed out
Although I am able to clone he same repository from command prompt using git clone command.
I had the same issue.
Configure your proxy if using one:
File->Settings->System Settings->HTTP Proxy
Another thing to try is to clone the project locally then add as new project in Pycharm. Afterwards I was able to do all git operations under VCS->git including add/commit/push for my project.
try to check whether you have given the path to Git executable correctly by testing it using test button next to it...(file>settings>version control>Git>path to Git Executable)
make sure you have given the git client path correctly..
C:\Program Files\Git\cmd\git.exe
I discovered an OSS project I've contributed to had moved to github. I installed hg-git and cloned a local repo from the git:// URL; then I made changes.
I then realized I really wanted my own github fork, so I made one; but I haven't been able to figure out quite how to switch my existing local repo. I've changed the local repo settings to use the git:// URL of my fork, and it can pull; but I can't push my changes up. It tells me to use the https:// URL, but when I make that change, I can neither pull nor push -- I get an error 406, "not acceptable."
The work done in the local repo is minimal, so I can redo it, but it'd be simpler if the local repo and my fork could just connect now.
UPDATE
I've installed Github for Windows so I could manage the SSH key. It generated a key (github_rsa) and attached it to my Github account.
I edited the hgrc file and added a [ui]ssh= setting pointing to the local git 'ssh' command (buried down in %APPDATA%\Local\Github).
With this, if I go into a "git-shell" window, which I guess spawns ssh-agent, then I can enter commands such as "hg incoming" and the connection is made. So I've got the remote repo URL right, and within the git-shell ecosystem, I've got the SSH keys set up right.
From a regular CMD.EXE window, the same command yields "Permission denied (publickey)". From TortoiseHg, the same error appears when I try an "incoming" action. I'd prefer to keep using TortoiseHg, but I'm not sure how to get it to use SSH.
FINAL UPDATE
For some reason, TortoisePlink doesn't want to play with github's SSH server, at least not with the Github-for-Windows-generated key. So I still have Github for Windows installed (not necessarily a bad thing, but superfluous to what I wanted to do).
To get hg and TortoiseHg to connect, I had to modify my project settings:
[ui]
ssh = %USERPROFILE%\AppData\Local\GitHub\<salt>\bin\ssh -i %USERPROFILE%\.ssh\github_rsa
That is: point to the SSH command, installed with portable GitHub, and specify the github-generated key on the command line. With this configuration, I don't need ssh-agent to be running.
You need to push via ssh, meaning you need to push via:
hg push git+ssh://git#github.com/<login>/<repo>
Note the usage of git# instead of your login in the first part of the URL. This actually matters; the server will figure out your credentials via the supplied SSH key.
You may also have to add your ssh key to your GitHub account first (per step 4 of this page).
This assumes that you created a fork of the original GitHub repository via the GitHub UI; pushing to an empty repository with hg-git may require additional steps.
I recently set up a github account to store the source code of a project I have been working on.
I am using egit eclipse plugin to push changes to github.
I successfully pushed the initial code and 2 subsequent changes. However when I attempted to push the third change I was not able. The following excepiton appears in the eclipse error log.
If someone could tell me the cause of this error, or tell me how I can go about debugging the problem it would be a great help.
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of push command
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
at org.eclipse.egit.core.op.PushOperation.run(PushOperation.java:227)
at org.eclipse.egit.ui.internal.push.PushOperationUI.execute(PushOperationUI.java:145)
at org.eclipse.egit.ui.internal.push.PushOperationUI$1.run(PushOperationUI.java:202)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.jgit.errors.TransportException: ssh://git#github.com/xxx/xxx.git: session is down
at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:154)
at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:118)
at org.eclipse.jgit.transport.JschSession.exec(JschSession.java:91)
at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:306)
at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:152)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:130)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1120)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:152)
... 4 more
Caused by: com.jcraft.jsch.JSchException: session is down
at com.jcraft.jsch.Session.openChannel(Session.java:750)
at org.eclipse.jgit.transport.JschSession$JschProcess.<init>(JschSession.java:147)
... 11 more
I experienced the same issue. Resolution follows:
Delete origin push and fetch in remote(Eclipse view --> Git repositories).
Close Eclipse.
Go to .ssh folder(Users/.ssh) and delete the key files(public and private).
Start eclipse and regenerate the keys(Window --> Preferences --> General tab --> Network connections --> SSH2).
Copy the key and add it to github/SSH Keys
In Eclipse add new remote and push.
Edit
You may not need to delete all the key files. If you have already added a key file previously (perhaps while setting up native Git), you can just add the name of that file in list of keys, and it will work.
This seemed to work for me:
Do everything Firoz and Nishant say except push: https://stackoverflow.com/a/9889350
Create or edit the following file on your desktop:
File : ~/.ssh/config
Content :
Host github.com
User [your_github_username]
Hostname github.com
PreferredAuthentications publickey
IdentityFile [path_to_private_key]
In your Eclipse Git Setup for your project do the following:
URI : git#github.com:[repo_owner_username]/[repo_name].git
Protocol : ssh
Username : git
Password : [leave_blank]
Save and push.
See this GitHub SSH Help page for useful info: http://help.github.com/ssh-issues/
Worked for me after initially suffering through "session is down" and "cannot open git-upload-pack" errors. Hope it helps everyone else too.
Good luck!
I faced the same problem and I found out solution which is extremely foolish.
I took following steps:
I logged into git repository of my project from browser and didn't sign out.
I copied the http url to push or pull from project repository from github.
I pasted the url in my eclipse plugin while pushing code (didn't use the already stored one even though both of them were same)
I don't know what and why but above steps have worked for me whenever I have faced above problem. I don't know why does eclipse throw such exceptions and why does it gets solved this way.
You can also try pushing using other ways outside of eclipse. for eg. `TortoiseGit` or `SmartGit` etc.
I had the same problem. I fixed it by pointing the JAVA_HOME variable to jdk 6. It was originally pointing to jdk 5.
I got this error message and it was fixed when one of my co-workers emailed me the two files id_rsa and id_rsa (MS Pub doc), I put them in C:Users\[userID]\.ssh, and shut down and restarted my IDE.
I had this issue with EGit and solved it at last. Somehow sometimes things get messed up. If you can not solve it through Eclipse just go to your "git" folder with git bash with Windows. With Linux it is even easier: just open the terminal.
This problem occurs because of username, password, and ssh keys getting messed up.
So, use the commands "git remote show origin" and make sure if the origin is username#github.com...... Sometimes Eclipse just puts "git" as a username so make sure you have the correct user name by changing it with the command git remote set-url origin https://usrname#github.com/restofthe url. It should automatically change the configurations in eclipse.
Best...
I also had this issue.
The following command in Git Bash, comes handy in such scenarios: git remote prune origin
This configured the Pull/Push in the corrupted branch.