gitLab: certificat issue, missing ssh public key - ssh

i can't get a point and understand how it works and what is necessary to do.
I have an account by GitLab and successfully generated private and public certificate in order to provide access to it. I done all steps as describes the https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair . Now i decided to create a new project and synchronize the state between gitLab project and one i created local by me. Because i have access to machine, which i used to create both certificate, i simply copied the public key from one machine (located in ~/.ssh folder) to current machine i am working in (in ~/.ssh folder). But it doesn't take any effect. I can't even execute the git clone command.
~> git clone git#gitlab.com:[myUser]/[myProject].git
Cloning into 'gate-controller'...
git#gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
i tried to figure out the reason and executed
~> ssh -vT git#gitlab.com
but to be a honest i can't interpret that response. I don't see in response any reference to my public keys file in ssh folder.
Could you please support me to solved the issue and understand, what is the problem ?
many thanks in advance
UPDATE:

You need the private key on any machine you're attempting to pull/push from. When authenticating with a service that has your public key (which any git service like Github, Gitlab, etc. will have) you need to use your private key when authenticating.
You can read more about ssh (which git uses when you don't use HTTPS auth) and PKI (Public Key Infrastructure) here https://www.ssh.com/pki/

Related

Why Can't I push to gitlab repository?

I recently created a new gitlab repository, and have set up a repository deployment key with the ssh public key from my computer. I manage to clone the project with ssh, but when I try to push changes into the repository, I get returned with a fatal error:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
In order to be able to push all the following should be implemented first
Make sure the project has been created under your username on
GitLab.com.
your Git username and email match your GitLab.com account for this
repository
the remote origin was set:
git remote add origin git#gitlab.com:user_name/work.git
an SSH public key was added to your GitLab.com account (if cloning
over using git or ssh).
ssh -T git#gitlab.com
Otherwise you could create a specific access token for the project you want to write to
The following guide could be useful https://blog.programster.org/gitlab-create-a-projects-access-token

SFTP - From WinSCP to Terminal Access

I have been able to set up SSH access to my Google Cloud Platform VM via SFTP using WinSCP, but I now wish to do the same using another VM.
I have tried the ssh-keygen -t rsa , ssh-copy-id demo#198.51.100.0 method but always come up against the "Permission denied (public key)" error which from researching seems to be a pretty widespread issue with few reliable fixes (all the ones I tried didn't work).
I used PuttyGen to create the public and private key, and inserted the public key onto the server just through GCP settings, adding it under the SSH settings for my instance.
I am just confused on what to do with the private key when simply trying to sftp through the terminal on a separate VM, as before I would load the private key into WinSCP settings. Is there a folder I need to place it in or?
Regarding your first issue of "Permission denied (public key)" error, please follow the troubleshooting in this link and this.
About your other question of "what to do with the private key when simply trying to sftp through the terminal", that depends on the settings of the specific the 3rd party SFTP tool you are using. To locate the locations of SSH key after generating them, please review this document.
Once you have added the public key in the VM, you would need to boot the VM for public key to take effect. Try rebooting it and try

Unable to clone a shared repository via ssh (mercurial)

I am having an issue with mercurial. I have ssh keys set up between my machine and the bitbucket account I am cloning with and I am able to clone any repo that I have created. However I am trying to clone a friends repo and she has given me read access, however when I try to clone via ssh I get the following error:
"remote: conq: repository access denied.
abort: no suitable response from remote hg!"
I am able to clone this repo via https and I am totally lost. It seems like an ssh issue but I am lost.
If none of the ssh troubleshooting BitBucket tips works, make sure you are not using sudo when trying to clone (as in "SSH to bitbucket returing Permission Denied (publickey)")
The key is to make sure your $HOME/.ssh/id_rsa(.pub) ssh files are used by the git clone command, and that your public key is in your account (which it should, since you can clone your own repos with ssh).

fatal: The remote end hung up unexpectedly by connectiong to GitHub

I've set up my local system for working with GitHub how descrided in the "Generating SSH Keys" How-To.
The key files and the known_hosts have been created, the public key has been added to the GitHub account, and I get the message "Hi ***! You've successfully authenticated, but GitHub does not provide shell access."
But all my attempts to do something, what needs a connection to the server (EDIT: with writing access) -- git clone, git push etc. -- end with an error:
fatal: The remote end hung up unexpectedly
EDIT:
I can clone, but only via HTTP (https://github.com/account/reponame.git) or Git Read-Only (git://github.com/account/reponame.git).
EDIT:
***#**** ~/.ssh
$ ssh-add -l
Could not open a connection to your authentication agent.
Although an ssh-agent daemon (ssh-agent.exe) is running.
Probably that is the problem.
The only instance where that error message pops up, while your public ssh key is correctly recorded by GitHub, is when
you try to clone a repo with a wrong case or an improper ssh url.
It should be:
git clone git#github.com:user/repo.git
you try to clone a repo for which you don't have write access (public repo), or any access (private repo).
From the GitHub page "Which remote URL should I use?"
To use these URLs, you must have write access to a public repo or any access to a private repo.
These URLs will not work with a public repo you do not have write access to.
the private key is passphrase protected and your authentication agent doesn't run properly:
$ ssh-add -l
Could not open a connection to your authentication agent.
For the last case, consider "How to run (git/ssh) authentication agent?" or "ssh-add complains: Could not open a connection to your authentication agent"
It works!
I've started the Pageant (PuTTY SSH authentication agent) and added my PuTTY private key id_rsa.pkk (exported with PuTTYgen (PuTTY Key Generator) from id_rsa) to it. Now I can write to my repos.
A small how-to for everyone, who has the same troubles I had:
0) Set up the local system for working with GitHub, how descrided in the "Generating SSH Keys" How-To.
1) Open PuTTYgen, load/import the (OpenSSH) private key id_rsa and save it (button Save private key) as id_rsa.pkk (in the same folder, where id_rsa is saved, -- ~/.ssh). You need this PuTTY variant of the key for PuTTY authentification with Pageant and (if you use it) TortoiseGit.
2a) Open Pageant (on my computer it's C:\Program Files (x86)\PuTTY\pageant.exe) and add the PuTTY private key. Or just open the PuTTY private key file (id_rsa.pkk) with Pageant.
2b) For TrtoiseGit I had only to set the SSH client (C:\Program Files (x86)\Git\bin\ssh.exe) in the global TrtoiseGit settings.
That's it.
I've got it working, but I don't have a deep understanding of this
thema and cannot provide a low level explanation of the solution and
the causes of this problem (and e.g why it was working in some clients
and wasn't in some others). So feel free to edit/comment this post, if
you can explain all this better.

Moved a gitlab instance, now having problems talking to gitolite

I had a working instance of Gitlab until a few weeks ago, when we had to move all the user directories to another disk b/c of resource constraints. I've gone through and fixed all the paths that I could find, and so now my gitlab instance is up and running again. Git appears to be working, and I pass the gitlab self-diagnostic test.
However, from a remote client that's previously worked, I get prompted to provide the git user's password, which suggests an ssh problem.
Looking in my .gitolite stuff (conf/gitolite.conf & the keydir), things look in order. My public key is in the keydir, and the rights are assigned in the gitolite.conf correctly.
EDIT: gitolite public keys were in the .ssh/authorized_keys file and the protections were as created by gitolite setup.
What am I missing?
My public key is in the keydir, and the rights are assigned in the gitolite.conf correctly.
This isn't enough.
For ssh to not ask you for a password, you need to check if your ~gitlab/.ssh/authorized_keys is complete (with the gitolite public keys in it, and with the right protections)
Check out the gitolite setup command (for gitolite V3).