GitBucket SSH Based Authentication - github

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

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

What is causing this error whenever I try to push to gist.github.com when pushing to all of my regular repositories work just fine?

Why does this occur? This is a secret gist, and I removed the PII from the block of code below:
user#NT696918742080085 MINGW64 ~/AppData/Roaming/Code/User (master)
$ git push -u origin master
The authenticity of host 'gist.github.com (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])? no
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Check first if your key is properly recognized:
ssh -Tv git#github.com
Then, following "Pushing to gist", double-check your gist SSH URL, or try (with 2FA activated), an HTTPS URL.

Private Github Repositories with Envoy

Anybody has any problems deploying with Laravel's envoy when using private Github repos?
When manually cloning my repo from the production server, the ssh key seems to be accessible but when using Envoy, I always get a "Permission denied (publickey) error.
Thanks
It is probably because the ssh key on your remote server requires a password.
If you change the Envoy.blade.php to perform some other task you should be able to establish whether you are connecting to your remote correctly.
#servers(['web' => 'user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Should return something like:
[user#domain.com]: On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
If you are connecting using a Mac or Linux you probably don't have to enter your password because your terminal is using ssh-agent which silently handles your authentication.
Wikipedia article on ssh-agent
When connecting over ssh, ssh-agent isn't running and the script is being prompted for a password which is where it is failing.
To get around this you could to generate a new key on the remote machine that doesn't use a password.
If you want to restrict the ssh key to a single repository on GitHub have a look at deploy keys
You need to pass the -A (as per the man page it - Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file) in you ssh string.
You will also need add your ssh key for agent forwarding (on the machine which can access the git remote which I assume be your localhost)
ssh-add -K ~/.ssh/your_private_key
Something like this
#servers(['web' => '-A user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Git remote commands should now work.

Authentication Failure on Github even after adding SSH key

I get fatal:Authenication Failure when I try to push code to my repo. I've added the public key on my github account as well. When I do :
ssh -i git#github.com
I get
Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.
Can anyone help?
Thanks
That depends on the remote url you have used.
If git remote -v returns:
https://github.com/username/reponame
Then your ssh setup won't matter. But this would work:
ssh://git#github.com:username/reponame
Another cause is linked to your private key: if it is pass-phrase protected, with a special character in it, that usually don't work well.
See here for other ssh causes of failure.
To replace your remote named origin, use git remote commands:
git remote set-url origin ssh://git#github.com:username/reponame
(as explained in the GitHub help page about changing the rmeote url)
If you see::
ssh: Could not resolve hostname github.com:amangupta052:
Name or service not known
fatal: The remote end hung up unexpectedly
Try the non-scp ssh syntax:
git remote set-url origin ssh://git#github.com/username/reponame
(note the '/' instead of the ':' after github.com)
Maybe this would have worked, as commented in this blog post:
git remote set-url origin git#github.com:username/reponame
(scp-like syntax, but without the ssh:// prefix)
As I mention here, an scp syntax usually means an ~/.ssh/config file to work properly.

connecting to github through server permission denied (public key)

I am connecting to github through my ftp server. I added the public key generated by my server then tried to connect and it is still giving me "permission denied", I attached a screenshot below.
You cannot just ssh into githubs servers in this way. Github's SSH server allows you to use git through their servers, not shell access. You get "permission denied" because you login with user github instead of git.
After adding your SSH public key to Github (which you've done correctly), just use git with the SSH remote.
If you have not a local repo yet, just use something like:
git clone git#github.com:Bumblebee-Project/Bumblebee.git
Otherwise, add a new remote to your existing git repo:
git add origin git#github.com:Bumblebee-Project/Bumblebee.git
After that, push your local repo with:
git push
See also http://help.github.com/remotes/