How to config SSH for gitlab? - ssh

In my experience of Github, I tought that I need to clone a repository with my user like user#gitlabhost.com. But when I try this, then it does not recognize my password from gitlab. Only cloning with gitlab user does work.
Can anybody please help me??? - How do I have to configure gitlab access right?

If you followed Installation Instructions of gitlab, then you must have installed it on an linux box under the user named git. Typically in a folder like this
/home/git/gitlab
Hence you should use git#gitlabhost.com
I am not sure what you mean by "configuring SSH". But since each user is expected to use her own keypair, there should be no problem in accessing gitlab managed repo's using normal git commands. Both the following should work
git clone ssh://git#gitlabhost.com/group/repo.git
git clone git#gitlabhost.com:group/repo.git
Each user must have set their own git identity (on their local machines) using
git config --global user.name "elitmus"
git config --global user.email "abc#gmail.com"
so that git can uniquely identify each user.

In my experience, I had to connect to the gitlab server, as the git user, and modify the authenticated_keys file, as it was filled with a bunch of random #'s. after clearing that, I added my SSH key in the GitLab GUI and was able to clone and push normally.
Hope that helps.

https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Generating a new SSH key and adding it to GitLab or github or any ssh-agent
for more information
https://help.github.com/en/github/authenticating-to-github/about-ssh

Related

Cannot clone from gitlab with SSH

I recently installed gitlab on an ubuntu 18.04 LTS instance. I am trying to clone a repo from GitLab.
My ssh config file is as below :
# ~/.ssh/config
User git
Hostname gitlab.com
IdentityFile ~/.ssh/id_ed25519
TCPKeepAlive yes
IdentitiesOnly yes
I have added the ed25519 public key to SSH keys in GitLab. When I try to clone the repo i get this issue-
$ git clone git#xxxx:root/test-project.git
Cloning into 'test-project'...
kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What am I doing wrong? I have checked out a couple of links on the internet but I cant figure out what I have done wrong.
I am able to clone and push if I use http instead of ssh.
git clone http://xxxx/root/test-project.git
Cloning into 'test-project'...
warning: You appear to have cloned an empty repository.
Why does http work and not ssh?
You have your ssh clone statement wrong: git clone username git#example.com:root/test.git
That statement would try to clone a repository named username into the location relative to your current path, git#example.com:root/test.git.
You want to leave out username:
git clone git#example.com:root/test.git
One alternative is Using sourcetree it will hit all the git clone and update command for you in just a click and also gives you a rich graphical representation on your repo and branches

ssh clone not working for gitlab server from windows bash (client)

I have created a new repository in gitlab with one readme file created init (through gitlab web portal) and i have added the user to the git repository for accessing (push/merge). Now the gitlab server is an ubuntu machine and i am trying to clone the repo from a different pc(win10) git bash terminal. where i have already configured user settings.
added git user name ,email id , git remote url
generated ssh key in win 10 client and updated the same in gitlab account settings (web interface -add ssh key)
$ git clone ravi#1xx.1xx.2xx.29:8181/ravi/test-project.git
Cloning into 'test-project'...
ravi#1xx.1xx.2xx.29's password:
fatal: '8181/ravi/test-project.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
can you please help me in resolving this issue

Git Extensions Authentication Error

I just downloaded git extensions. It is configured to use putty that comes with the installation. I used putty to create a private and public key and I have the agent started and I have added the private key.
I am using bitbucket and I have loaded my public key to my bitbucket account.
I get the ssh clone link from bitbucket and go to clone it in git extensions, I load the SSH key and hit clone and I get this error message.
Error Message
I have an SSH key loaded. Why is it saying I need to load a key? I uninstalled gitextensions and generated different keys. I looked at all the settings, i'm not sure what i'm doing wrong.
Git Extensions SSH settings
Windows 10
Putty 0.70
Git extensions 2.51.01
bitbucket.org
I found the answer.
When you copy past the git command from bitbucket, it is the wrong syntax for git Extensions.
You will copy something like this:
git clone git#bitbucket.org:guitardenver/led-pad-pcb.git
But you need to remove the "git clone" part for it to work with git Extensions.
git#bitbucket.org:guitardenver/led-pad-pcb.git

Deploy to server with CircleCI and SCP

Say I have a repo that I'd like CircleCI to deploy after finishing the test sequence and the code is like so:
deployment:
staging:
branch: master
commands:
- scp -r wp-content/plugins/timespan username#servername.provider.host:public_html/wp-content/plugins
That works locally because I've set up the authentication that's necessary. But with CircleCI, that context isn't there and so it prompts for a password which I can't enter by having it on the next line, i.e. - passw0rd.
So I've tried a couple other things without success: 1) adding an ssh key into Circle and it rejects that by saying they don't support encrypted keys. 2) I tried using sshpass but wasn't able to add it as a dependency because of not knowing how nor which package manager to use to get it in.
Perhaps someone can enlighten me? I don't think this is too far off but am missing something.
You don't have to encrypt the SSH key.
I'm using CircleCi for the exact same thing, just add the uncrypted key to your SSH Permissions (you'll find it in your Project Settings on CircleCi in the "Permissions" section. Of course you will need the public key in your servers authorized_keys.
Otherwise you can add additional packages through your circle.yml: https://circleci.com/docs/installing-custom-software/
You can use your circle.yml file to run arbitrary commands against your build environment. You have root access to your environment via sudo, so you should be able to customize it to your heart’s content!
Example:
dependencies:
pre:
- sudo apt-get update; sudo apt-get install ssh-pass
I hope this will help you.
sshpass only needs to be installed on the client side. You do not need to install it on the server.
I am not familiar with CircleCI, but it sounds like you are trying to get it to install sshpass on the server, which is completely unnecessary. Just do sshpass -ppassw0rd scp ... in your CircleCI deployment script after having installed it on the server that runs CircleCI, and you should be fine.

Pulling my github repository and deploying it on apache

My Setup:
EC2 Instance with Ubuntu
Apache2 installed (publishes /var/www folder)
Git installed
SSH Keys Set:
$ ssh -T git#github.com
Hi User! You've successfully authenticated, but GitHub does not provide shell access.
My intention:
I want to pull a specific repository on github and publish it onto apache (basically puting the files into /var/www)
Where I am stuck:
Permissions of /var/www are set to root
trying to use sudo for cloning the repo results in a denied permission (root user uses different ssh keys?)
Where to clone my repo to? What diretory is appropriate for that?
How to copy the files then to /var/www?
I am quite new to Linux, so please help me :-) Thank you
I used root's ssh key and that works!
Just created new keys by using the sudo command and used them with github.