Still requiring login after SSH authentication - github

I followed everything in the GitHub tutorial: https://help.github.com/articles/generating-ssh-keys
I did all the commands in the directory of my repository.
I reached the end of tutorial successfully and got the message: "Hi username! You've successfully authenticated, but GitHub does not # provide shell access."
However when I tried to do things such as push it still requested for my username and password.

Check your remotes via git remote -v.
https:// URLs will always ask for a password, unless you configure a credential helper. More info on that in this question.
The simplest solution for password-less git access would be to use the git remote set-url command and set an SSH url for the existing repo.
In your case, git remote set-url origin git#github.com:name/repo.
Then you should be able to git push origin <branch> without being asked for a password.

Good that you have correctly setup your git ssh now you need to reclone the git repository with ssh for example previously you would have done something like this :
git clone https://github.com/dangrossman/bootstrap-daterangepicker.git
this was a https clone now you need to clone with ssh as
git clone git#github.com:dangrossman/bootstrap-daterangepicker.git
you can find the ssh link from your github account same place where you found your https link.
After this you can easily push without your password prompt .
It might though ask for your ssh unlock password. You then need to enter the paraphase you gave during the creation of your ssh key . If you left it blank it might not prompt for it .

I was able to stop the username & password prompt by opening .git/config from the base repo directory and changing the remote URL.
For example:
[remote "origin"]
url = https://github.com/username/my-repo.git
should be changed to:
[remote "origin"]
url = git#github.com:username/my-repo.git

I tried the answer marked as correct but couldn't make it work. This worked for me instead git remote set-url origin ssh://git#github.com/username/reponame

Related

Pushing to GitHub without a key

I am using GitHub and C9 on a work computer and but GitHub will stop reading my SSH key after a few hours. IDK if it is because I am using my work computer (job is not currently programming), but is there a way I can push my code without an SSH key
First, check that your remote URL is indeed an ssh one:
cd /path/to/my/local/cloned/repo
git remote -v
If it is (git#github.com:user/repo), check what ssh -Tv git#github.com returns.
If SSH does not work (because SSH port might be blocked at work), switch to an HTTPS URL:
git remote set-url origin https://github.com/user/repo
From there, make sure git config credential.helper does reference an helper (like "manager" on Windows), and you will be prompted for your GitHub account username/password at the first push. After that, your credentials will be cached.

GitHub: invalid username or password

I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message
Password for 'https://git#github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://git#github.com/eurydyce/MDANSE.git/'
However, setting my ssh key to github seems ok. Indeed, when I do a ssh -T git#github.com I get
Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.
Which seems to indicate that everything is OK from that side (eurydyce being my github username). I strictly followed the instructions given on github and the recommendations of many stack discussion but no way. Would you have any idea of what I may have done wrong?
After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone, git fetch, git pull or git push:
$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://your_user_name#github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'
Why this is happening
From the GitHub Help documentation:
After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password.
...
For example, when you access a repository using Git on the command line using commands like git clone, git fetch, git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password.
How to fix it
Generate a Personal Access Token. (Detailed guide on Creating a personal access token for the command line.)
Copy the Personal Access Token.
Re-attempt the command you were trying and use Personal Access Token in the place of your password.
Related question:
https://stackoverflow.com/a/21374369/101662
https://git#github.com/eurydyce/MDANSE.git is not an ssh url, it is an https one (which would require your GitHub account name, instead of 'git').
Try to use ssh://git#github.com:eurydyce/MDANSE.git or just git#github.com:eurydyce/MDANSE.git
git remote set-url origin git#github.com:eurydyce/MDANSE.git
The OP Pellegrini Eric adds:
That's what I did in my ~/.gitconfig file that contains currently the following entries [remote "origin"] url=git#github.com:eurydyce/MDANSE.git
This should not be in your global config (the one in ~/).
You could check git config -l in your repo: that url should be declared in the local config: <yourrepo>/.git/config.
So make sure you are in the repo path when doing the git remote set-url command.
As noted in Oliver's answer, an HTTPS URL would not use username/password if two-factor authentication (2FA) is activated.
In that case, the password should be a PAT (personal access token) as seen in "Using a token on the command line".
That applies only for HTTPS URLS, SSH is not affected by this limitation.
Solution steps for Windows users:
Control Panel
Credential Manager
Click Windows Credentials
In Generic Credential section ,there would be git url, update username and password
Restart Git Bash and try for clone
Note:
If you didn't find git url in Generic Credential section then follow below answer
https://stackoverflow.com/a/55858690/7372432
If like me you just updated your password and ran git push to run into this issue, then there's a super easy fix.
For Mac users only. You need to delete your OSX Keychain access entries for GitHub. You can do it via terminal by running the following commands.
Deleting your credentials via the command line
Through the command line, you can use the credential helper directly to erase the keychain entry.
To do this, type the following command:
git credential-osxkeychain erase
host=github.com
protocol=https
# [Now Press Return]
If it's successful, nothing will print out. To test that it works, try and clone a repository from GitHub or run your previous action again like in my case git push. If you are prompted for a password, the keychain entry was deleted.
When using the https:// URL to connect to your remote repository, then Git will not use SSH as authentication but will instead try a basic authentication over HTTPS. Usually, you would just use the URL without a username, e.g. https://github.com/username/repository.git, and Git would then prompt you to enter both a username (your GitHub username) and your password.
If you use https://something#github.com/username/repository.git, then you have preset the username Git will use for authentication: something. Since you used https://git#github.com, Git will try to log in using the git username for which your password of course doesn’t work. So you will have to use your username instead.
The alternative is actually to use SSH for authentication. That way you will avoid having to type your password all the time; and since it already seems to work, that’s what you should be using.
To do that, you need to change your remote URL though, so Git knows that it needs to connect via SSH. The format is then this: git#github.com:username/repository. To update your URL use this command:
git remote set-url origin git#github.com:username/repository
Instead of git pull also try git pull origin master
I changed password, and the first command gave error:
$ git pull
remote: Invalid username or password.
fatal: Authentication failed for ...
After git pull origin master, it asked for password and seemed to update itself
2FA is enabled and getting error remote: Invalid username or password.
fatal: Authentication failed for
If you set 2FA is enabled in GitHub you will need to enter a personal access token instead of a 2FA code and your GitHub password.
How to fix it
https://github.com/settings/tokens generated token
Copy the Personal Access Token
Now enter Personal Access Token in the place of your password during git operation
just try to push it to your branch again. This will ask your username and password again, so you can feed in the changed password. So that your new password will be stored again in the cache.
This is the answer.
Set the github token:
https://github.com/settings/tokens
And then:
git remote set-url origin https://[token]#github.com/your_repository
I am getting this while cloning app from bitbucket:
Cloning into 'YourAppName'...
Password for 'https://youruser id':
remote: Invalid username or password
I solved it. Here you need to create password for your userid
Click on Your profile and settings
Then Create app password choose your name password will generated ,paste that password to terminal
That problem happens sometimes due to wrong password. Please check if you are linked with AD password (Active Directory Password) and you recently changed you AD password but still trying git command with old password or not.
Update old AD password
Control Panel > Credential Manager > Windows Credential > change github password with my new AD password
I have got the success using the following commands.
git config --unset-all credential.helper
git config --global --unset-all credential.helper
git config --system --unset-all credential.helper
Try and let me know if these are working for you.
No need to rely on Generating a Personal Access Token and then trying and use Personal Access Token in the place of your password.
Quick fix is to set your remote URL to point to ssh not https.
Do this git remote set-url origin git#github.com:username/repository
I did:
$git pull origin master
Then it asked for the [Username] & [Password] and it seems to be working fine now.
If you have just enabled 2FA :
Modify hidden config file in ./git hidden folder as follow :
[remote "origin"]
url = https://username:PUT_YOUR_2FA_TOKEN_HERE#github.com/project/project.git
Try this:
# git remote set-url origin git#github.com:username/repository
Run Below command, and after than on every push and pull it will ask you to enter the username and password.
git config credential.helper ""
now when you pull/push you will be asked for git credentials. weather you are running through command prompt or Intellij Git.
Disabling 2 factor authentication at github worked for me.
I see that there is a deleted answer that says this, with the deletion reason as "does not answer the question". If it works, then I think it answers the question...
You might be getting this error because you have updated your password. So on Terminal first make sure you clear your GitHub credentials from the keychain and then push your changes to your repo, terminal will ask for your username and password.
In case you get this error message in this situation:
using github for entreprise
using credential.helper=wincred in git config
using your windows credentials which you changed recently
Then look at this answer:
https://stackoverflow.com/a/39608906/521257
Windows stores credentials in a credentials manager, clear it or update it.
Control panel
Credential manager
Look for options webcredentials and windows credentials
in either one you will find github credentials fix it with correct credentials
open new instance of git bash you should be able to perform your git commands.
This worked for me, I was able to pull and push into my remote repo.
I had the same issue. And I solved it by changing the remote branch's path from https://github.com/YourName/RepoName to git#github.com:YourName/RepoName.git in the repo's settings of the client app.
I'm constantly running into this problem.
Make sure you set git --config user.name "" and not your real name, which I've done a few times..
I just disable the Two-factor authentication and try again. It works for me.
Since you probably want to keep 2FA enabled for your account, you can set up a ssh key and that way you won't need to type your Github credentials every time you want to push work to Github.
You can find all the ssh setup steps in the documentation. First, make sure you don't currently have any ssh keys (id_rsa.pub, etc.) with $ ls -al ~/.ssh
I fixed my issue by installing GitHub CLI and running gh auth login
See:
https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git#github-cli
I had the same issue
$ git clone https://github.com/sample-url.git
Cloning into 'Project'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/sample-url.git/'
I just git init first and then git clone <clone-url>
git init
git clone https://github.com/your-clone-Url
It worked for me.
There is a issue on Windows using cmd-Greetings
There is a issue on Windows using cmd-Greetings who will not let you clone private repositories. Remove that cmd-greeting described in this documentation (keyword Command Processor):
Known-Issues
I can confirm that other clients like SourceTree, GitKraken, Tower and TortoiseGit affected to this issue too.
There are many reasons why this might happen. In my case, none of the solutions worked. In particular, git pull origin master did not ask me for my username and password.
I was on Windows with a github password recently changed. I was using the credential manager to manage my password. Here is what worked for me:
Confirm you are using the credential manager for git:
git config --list
…
credential.helper=manager
Run a new command prompt as administrator
List all stored credential with cmdkey /list from C:\WINDOWS\system32>
Remove the github target with cmdkey /delete:<target name>. In my case, the target name was github.<companyname>.com
Open a new prompt and run a git command. You should get a popup asking for your usernmame and password. After providing the new credentials, it won't ask you for it again.
When I faced this issue all I did to resolve it was to Generate new token from my github dashboard and paste the following code in my terminal
$ git remote set-url origin https://your-github-username:your-github-token#github.com/your-github-username/your-github-repo.git

Git hub pushing to a forked repo

I'm new to github and I couldn't seem to find a solution to my problem, so bear with me a little.
I'm trying to push changes that I've made to a forked repo via command line on an ec2 ubuntu instance from aws. After making changes to my file, I committed the file I changed and then pushed it over to git:
ubuntu#ip-172-31-33-24:~/bitstarter$ git push origin master
Username for 'https://www.github.com': edasaur
Password for 'https://edasaur#www.github.com':
fatal: Authentication failed
I'm hypothesizing that this might be an issue with the fact that I'm pushing over to a forked repo because when I attempted to commit and push changes over to a repository that I started, it seemed to work. However, I'm at a loss at what to do. When I tested whether my SSH key worked via the command:
ubuntu#ip-172-31-33-24:~/bitstarter$ ssh -T git#github.com
Hi edasaur! You've successfully authenticated, but GitHub does not provide shell access.
Thanks in advance!
First, you are pushing using an https address, so any ssh settings you might have won't have any bearing on the completion of the (https) push.
Second, the right https url you should use is:
https://edasaur#github.com/edasaur/bitstarter.git
(no need for www.github.com)
(I like to put the username in the url: that is one less data to enter when pushing)
That means you can set your url with:
git remote set-url origin https://edasaur#github.com/edasaur/bitstarter.git
Third, double-check your password (and see if there is any special character in it like an '#', which might not be directly supported over an http query)
If nothing works, you can still fallback on ssh url:
git remote set-url origin git#github.com:edasaur/bitstarter.git

Git wont push. Asking for user/pass

I'm trying to push some of my projects to my github account but when i try it wont let me. I was able to push just a couple of days ago and now I cant.
I tried
running
cd existing_git_repo
git remote add origin https://github.com/Ommy/MapTool.git
git push -u origin master
but on git bash it asks for
Username for 'https://github.com':
I try my username/password which doesn't work.
I tried running
git config --global user.name "Fasih Awan"
git config --global user.email *********#gmail.com
but even with that it still asks for the username/password. I created the repository on github before pushing but it still does this. What am I doing wrong?
If you are using HTTP for the remote repository you will still need to type your username and password. If you want to use SSH keys, use the SSH protocol for the remote repository. There is a guide here on how to configure SSH keys.
Either use password caching or SSH. It's all nicely explained here: https://help.github.com/articles/set-up-git
Make sure that you have uploaded your public key to github. The only thing you should be asked for is a password for you public key, not a username.

problem in pushing to github

I have created a repository on github named pygame. Created a clone and added files and commited.but when I attempt to push I receive the following error:
git push -u origin master
error: The requested URL returned error: 403 while accessing https://github.com/amalapk/pygame/info/refs
fatal: HTTP request failed
I can ssh to git#github.com and receive the notice that I logged in successfully, but can't push to my repository.
I recently experienced this problem when setting up a new clone of my github project.
You need to include your username in the URL to your project, in the form
https://user#github.com/project/...
For example, the URL provided for my test github is this:
https://github.com/jdblair/test.git
If I add my username to it, like this, then I'm able to push and pull from github with no problem:
https://jdblair#github.com/jdblair/test.git
It is easiest to use the URL that contains the username starting from when you clone a project.
You can change the URL for an existing project like this:
git remote set-url origin https://user#github.com/project/foo/bar.git
You can use the ssh authentication instead if you want, but that's a separate setup process.
Github now is asking us to use git 1.7.10 or later:
https://help.github.com/articles/error-the-requested-url-returned-error-403
The GitHub Remote page mentions the read/write addresses for a repo:
Make sure your clone address is like:
https://github.com/username/yourRepo.git
And that you have defined:
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email#youremail.com"
Should you use a git address (without ssh), you would also need:
git config --global github.user username
git config --global github.token 0123456789yourf0123456789token # no longer needed
(with your token coming from “Account Settings” > Click “Account Admin.”)
Update 2013: you still can generate a token (see "Creating an access token for command-line use"), but you would use it as a password for https url.
Actually, if you activate the 2FA (two-factor authentication) mechanism on GitHub, you will need a token for your https url (because your regular password would trigger the second-step verification).
See "Configure Git clients, like GitHub for Windows, to not ask for authentication"
See more at "Which remote URL should I use?".
It's all in the remote.
Change your current remote from https://github.com/amalapk/pygame.git to git#github.com:amalapk/pygame.git and enjoy.
To do this... (assuming your current remote is called origin)
git remote set-url origin git#github.com:amalapk/pygame.git
In my case getting rid of such error message was resolved this way:
Person was simply added to github repository as a colaborator.
Thats it - error vanished magically.
Committing to github from server this is what worked for me in the terminal or git bash
To create a remote to github.com try:
git remote add origin https://put your username here#github.com/put your git username here/put your repository name here
To change the remote just do:
git remote set-url origin https://put your username here#github.com/put your git username here/the name of your repository here
Please follow the instructions on http://help.github.com/create-a-repo/
You have cloned your repository with the public read only url.
RTFM