I
I
ITemka2022-03-09 06:34:25
git
ITemka, 2022-03-09 06:34:25

Why can't I create a bare repository on a Git collaboration server using SSH?

At the moment I am actively learning Git and I am interested in the topic of working with the server.

I know that in order to create a Git server, you first need to create a bare repository. I did this using the command git clone --bare test_project clone_test_project.git . Here is the first question: is it necessary to write .git at the end of the bare repository name? The question is stupid, probably, but I didn’t understand the question, so I can’t check whether everything will work if I don’t write it in the .git name.

Next, I used the documentation - http://git-scm.com/book/ru/v2/Git-on-server-Install...

I messed up at the stage of placing this very bare repository on the server. The documentation said that to do this, you need to enter the command scp -r my_project.git [email protected]:/srv/git. I don't understand the [email protected]:/srv/Git part. What is it? After sitting for a while, I had a theory where this can be taken from. I host my repository on the gitlab server. Therefore, in order to upload your repository on the server, you first need to create an empty project there (again, I think so, because I did not find a clear instruction that suits me). I did this and went to its main page. There I clicked on the blue Clone button and I got two options for linking to my project in gitlab. I thought this is what I need. I copied where Clone with SSH was written, since it is the ssh protocol that I want to use to access my repository on the server. It turned out [email protected]:potemkin277/test-project.git . And in the end my whole command to put the bare repository on the server was scp -r clone_test_project.git [email protected]:potemkin277/test-project.git .

This is where the problem arises. When I type this into git BASH after going into this bare repository folder, I get an error:

[email protected]: Permission denied (publickey, keyboard-interactive).
lost connection

After digging around in the forums, I realized that the problem here is that my key pair is not registered in the authorized_keys file. To be honest, I didn’t quite understand this either, because I’m also just starting to learn the ssh protocol. But somehow I did not find this file anywhere. I tried to create my own in the .ssh folder and copied the public part of my key pair there. It was just a cry of despair and, as expected, nothing came of it. For ssh, if anything, I use the PuTTY program.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kuznetsov, 2022-03-09
@ITemka

Is it necessary to prescribe .git at the end of the bare repository name?

This is not the name of the repository, but the name of the folder. It can be anything.
Next, I used the documentation 4.2 Git on the server - Installing Git on the server

Wrong head? If you already have a GitLab server, then read about it: 4.8 Git on the server - GitLab
I don't understand the [email protected]:/srv/Git part

user- the name under which you are authorized via ssh on the external computer
git.example.com- the address of this external computer
/srv/Git- the path to the folder with the repository inside the external computer
But you don't need all this if you already have a server. And GitLab is exactly the server.
Do not invent anything and do according to the documentation.
there you first need to create an empty project

This already creates an empty bare repository. You don't have to copy anything by hand. Yes, and you do not have the right to such access.
I clicked on the blue Clone button and I got two link options

If you work through the https protocol, then you do not have to create keys. Everything will become much easier.
Then you either clone it to your computer via
git clone [email protected]:potemkin277/test-project.git

Or link your existing repository to it
git remote add origin [email protected]:potemkin277/test-project.git

Then push your branch there and link the local and external branches-u
git push -u origin ветка

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question