Getting error while clone the gitrepo using ssh-key - github

I have created a public key after I have pasted it on GitHub then I have tried to do git clone.
But while doing the clone, it is asking for the password:
Did i do anything wrong?

First, make sure you have pasted your SSH public key in your User SSH setting page of your local GitHub instance, not github.com.
Second, test if you are correctly authenticated with:
ssh -Tv git#stg-...github-....local
^^^^^^^^^^^^^^^^^^^^^^^
your local GitHub server name
You should see which key is used, and if yours is selected.

Related

Registration in the git hub, git and the repository problem

I want to make a repository in GitHub for the first time and now it gives me this error
Username for 'https://github.com': ******`enter username here`
Password for 'https://m.erfanpld#github.com': `enter password here`
remote: Permission to MErfanPld/web.git denied to MErfanPld.
fatal: unable to access 'https://github.com/MErfanPld/web.git/': The requested URL returned error: 403
Thank you for your help
There are two ways you can access Github repositories when they are private.
HTTPS
SSH
I recommend the second method, You must create an ssh key using the command below
ssh-keygen
Now You can print Your ssh public key using the command bellow in Linux
cat ~/.ssh/id_rsa.pub
Use this link as a hint to manage your ssh keys.
Finally, you need to add your public ssh key into GitHub, Github explains this here with a picture guide. Now through ssh public key and without the need to log in with a username and password every single time, You can access your private repositories in a secure way.
Best regards

GitBucket SSH Based Authentication

I configured the SSH based authentication as below
Created a public key on my UNIX server
Added the public key on my Bitbucket repository with reading and write privileges (also tried it at account level)
changed the URL from https to SSH at bitbucket and Unix server
verified the URL using and it is displaying SSH URL only
Then Tried to push, but I am getting the below error:
Permission denied (public key). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I have read and write access to the repository
push command
git push -u origin master
Any idea?
You should try:
GIT_SSH_COMMAND="ssh -Tv" git push
You will see what Git is using as an SSH key, and if there are any error messages.
If the error persists, it is possible there is something preventing SSH to operate properly (as in here, when not connected to a VPN)
Using HTTPS, of course, is a workaround:
git remote set-url origin https://git#bitbucket.XXX.com/XXX.com/XXX.git
After discussion, the missing step was to add the private key to the ssh-agent
ssh-add OEDQ_BIT added the private key

Is it required to regenerate SSH key for new EC2 instance when cloning a github repo via SSH URL?

As discussed here and here, it seems that connecting to github repo via SSH protocol requires a newly generated key.
I just tried today on my EC2 instance and failed to git pull my github repo; i.e. reusing a key pair generated on another EC2 instance is not working.
So I want to raise the issue here so that we all can confirm this - Is it required to regenerate ssh key for new EC2 instance when git clone a github repo?
p.s.
What I have done and failed on Ubuntu Server 14.04 are as below.
ssh key files
cloned key in ~/.ssh
public key registered in github
calling git
run ssh -vT git#github.com
run git clone git#github.com:MY_USER/MY_PROJECT.git MY_FOLDER get Public key denied error
So I want to raise the issue here so that we all can confirm this - Is it required to regenerate ssh key for new EC2 instance when git clone a github repo?
in brief
No need for re-generated key.
details
Reusing the key from different instance SHOULD WORK too, but you need to place it to the proper location with the correct permissions.
You may try
Restart your SSH connection to the EC2.
Specify the private key via GIT_SSH_COMMAND prefix
sudo GIT_SSH_COMMAND="ssh -i ~/.ssh/YOUR_PRIVATE_KEY" git clone git#github.com:USER/PROJECT.git YOUR_LOCAL_DIR
p.s.
You can clone over HTTPS without any SSH key.

Login required on one github project but not others

I AM ABLE to push to my other projects on git w/o requiring login.
However on a new private project, I am now required to enter username/password. I verified my keys.
Interesting that I run ssh -vv LarryEitel#github.com and after verbose log, it returns permission denied.
Any suggestions would be most appreciated.
Thank you :)
You probably cloned this specific repository using the https:// URL instead of the ssh URL given on GitHub homepage. You can check that by taking a look at the .git/config file.
Also, to test ssh connection, you should do:
ssh -vv git#github.com
Access is provided by your public ssh key stored on GitHub and not by your user ID.

Github wrong username

I have setup with guthub with a previous github account on this computer called myaccount when i run this command
ssh -T git#github.com
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access.
Ok but i have now setup a new github account called samaccount but i cant run this command i get this error.
git push -u origin master
i get this error
ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount.
I dont want it to use myaccount it should be using samaccount !!!
i have followed all the steps here http://help.github.com/mac-set-up-git/
setup brand new ssh key.
and also run this command many times
git config --global user.name "samaccount"
but it still uses myaccount its sooo annoying where am i going wrong???
GitHub recognizes you as myaccount because SSH is using a key that corresponds to a public key that has been added to the myaccount account on the GitHub website.
If you want to switch entirely to using the sameueleast account instead of myaccount, you can do the following:
Login to GitHub's website as myaccount
Go to "Account Settings"
Go to "SSH Public Keys"
Delete your public key from that list
Logout
Login to GitHub's website as samueleast
Go to "Account Settings" -> "SSH Public Keys"
Select "Add another public key" and paste in the contents of your public key. You public key will (probably) be called id_rsa.pub or id_dsa.pub and be in your .ssh directory.
On the other hand, if you want to be able to use either myaccount or samueleast when pushing to GitHub, you will need to create aliases for git#github.com in ~/.ssh/config, such as:
Host github-myaccount
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_dsa-myaccount.pub
Host github-samueleast
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_dsa-samueleast.pub
That assumes you've generated a second SSH keypair and given them names as above. Then you need to make sure that you are using the appropriate alias in the URLs of your git remotes. For example, if you want to change your origin remote so that pushing to origin means "pushing to origin as samueleast", you could do:
git remote set-url origin \
git#github-samueleast:samueleast/Samuel-East-S3-Audio-Playlist-Player.git