Skip to content

Commit

Permalink
Переклад "Налаштування Серверу" (Ґіт на сервері)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedrok committed May 25, 2015
1 parent 61cea01 commit 94f1168
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 39 deletions.
108 changes: 70 additions & 38 deletions book/04-git-server/sections/setting-up-server.asc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[[_setting_up_server]]
=== Setting Up the Server

Let's walk through setting up SSH access on the server side.
In this example, you'll use the `authorized_keys` method for authenticating your users.
We also assume you're running a standard Linux distribution like Ubuntu.
First, you create a `git` user and a `.ssh` directory for that user.
//=== Setting Up the Server
=== Налаштування Серверу

//Let's walk through setting up SSH access on the server side.
Розглянемо покрокове налаштування SSH доступу на сервері.
//In this example, you'll use the `authorized_keys` method for authenticating your users.
У цьому прикладі, ми використаємо метод авторизованих ключів (`authorized_keys`) для авторизації ваших користувачів.
//We also assume you're running a standard Linux distribution like Ubuntu.
Ми знови припустимо, що на вашому сервері стандартний дистрибутив Лінукс, наприклад Ubuntu.
//First, you create a `git` user and a `.ssh` directory for that user.
Спершу, створемо користувача `git` та теку `.ssh` для цього користувача.

[source,console]
----
Expand All @@ -15,9 +20,12 @@ $ mkdir .ssh && chmod 700 .ssh
$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
----

Next, you need to add some developer SSH public keys to the `authorized_keys` file for the `git` user.
Let's assume you have some trusted public keys and have saved them to temporary files.
Again, the public keys look something like this:
//Next, you need to add some developer SSH public keys to the `authorized_keys` file for the `git` user.
Далі, треба додати публічні SSH ключі якогось програміста до файлу `authorized_keys` користувача `git`.
//Let's assume you have some trusted public keys and have saved them to temporary files.
Припустимо, що у вас є перевірені публічні ключі та ви їх зберегли до тимчасових файлів.
//Again, the public keys look something like this:
Нагадаємо, публічні ключі виглядають схоже на:

[source,console]
----
Expand All @@ -30,16 +38,18 @@ O7TCUSBdLQlgMVOFq1I2uPWQOkOWQAHukEOmfjy2jctxSDBQ220ymjaNsHT4kgtZg2AYYgPq
dAv8JggJICUvax2T9va5 gsg-keypair
----

You just append them to the `git` user's `authorized_keys` file in its `.ssh` directory:
//You just append them to the `git` user's `authorized_keys` file in its `.ssh` directory:
Ви просто долучаєте їх до файлу `authorized_keys` користувача `git` в його теці `.ssh`:

[source,console]
----
$ cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.josie.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.jessica.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.oleksandr.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.taras.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.olga.pub >> ~/.ssh/authorized_keys
----

Now, you can set up an empty repository for them by running `git init` with the `--bare` option, which initializes the repository without a working directory:(((git commands, init, bare)))
//Now, you can set up an empty repository for them by running `git init` with the `--bare` option, which initializes the repository without a working directory:(((git commands, init, bare)))
Тепер ви можете налаштувати порожнє сховище для них за допомогою `git init` з опцією `--bare`, яка створює сховище без робочої теки:(((git commands, init, bare)))

[source,console]
----
Expand All @@ -50,14 +60,18 @@ $ git init --bare
Initialized empty Git repository in /opt/git/project.git/
----

Then, John, Josie, or Jessica can push the first version of their project into that repository by adding it as a remote and pushing up a branch.
Note that someone must shell onto the machine and create a bare repository every time you want to add a project.
Let's use `gitserver` as the hostname of the server on which you've set up your `git` user and repository.
If you're running it internally, and you set up DNS for `gitserver` to point to that server, then you can use the commands pretty much as is (assuming that `myproject` is an existing project with files in it):
//Then, John, Josie, or Jessica can push the first version of their project into that repository by adding it as a remote and pushing up a branch.
Після цього, Олександр, Тарас та Ольга можуть викласти першу версію свого проекту до того сховища, якщо додадуть його як віддалене сховище та викладуть до нього гілку.
//Note that someone must shell onto the machine and create a bare repository every time you want to add a project.
Завважте що хтось має заходити до машини та створювати очищене сховище щоразу, коли ви хочете додати проект.
//Let's use `gitserver` as the hostname of the server on which you've set up your `git` user and repository.
Використаймо `gitserver` як ім'я хосту (`hostname`) серверу, на якоми ви налаштували користувача `git` та сховище.
//If you're running it internally, and you set up DNS for `gitserver` to point to that server, then you can use the commands pretty much as is (assuming that `myproject` is an existing project with files in it):
Якщо ви ваш сервер працює у внутрішній мережі, та ви налаштуєте DNS щоб ім'я `gitserver` вказувало на ваш сервер, то ви можете використовувати команди як і раніше (припустимо, що `myproject` це існуючий проект з файлами):

[source,console]
----
# on Johns computer
# на машині Олександра
$ cd myproject
$ git init
$ git add .
Expand All @@ -66,42 +80,56 @@ $ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master
----

At this point, the others can clone it down and push changes back up just as easily:
//At this point, the others can clone it down and push changes back up just as easily:
Після цього, усі інші можуть зробити клон цього сховища, та викладати зміни назад так само легко:

[source,console]
----
$ git clone git@gitserver:/opt/git/project.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git commit -am 'виправлення файлу README'
$ git push origin master
----

With this method, you can quickly get a read/write Git server up and running for a handful of developers.
//With this method, you can quickly get a read/write Git server up and running for a handful of developers.
За допомогою цього метода, ви можете швидко отримати працюючий сервер Ґіт з доступом на читання та запис для декількох програмістів.

You should note that currently all these users can also log into the server and get a shell as the `git` user. If you want to restrict that, you will have to change the shell to something else in the `passwd` file.
//You should note that currently all these users can also log into the server and get a shell as the `git` user. If you want to restrict that, you will have to change the shell to something else in the `passwd` file.
Зауважте, що наразі усі ці користувачі також можуть заходити на сервер та отримують доступ до оболонки (shell) як користувач `git`. Якщо ви не хочете цього дозволяти, вам треба змінити програму оболонки на щось інше у файлі `passwd`.

You can easily restrict the `git` user to only doing Git activities with a limited shell tool called `git-shell` that comes with Git.
If you set this as your `git` user's login shell, then the `git` user can't have normal shell access to your server.
To use this, specify `git-shell` instead of bash or csh for your user's login shell.
To do so, you must first add `git-shell` to `/etc/shells` if it's not already there:
//You can easily restrict the `git` user to only doing Git activities with a limited shell tool called `git-shell` that comes with Git.
Ви легко можете обмежити користувача `git` до виключно активності Ґіта за допомогою утиліти `git-shell`, що входить до поставки Ґіта.
//If you set this as your `git` user's login shell, then the `git` user can't have normal shell access to your server.
Якщо ви вкажете її для вашого користувача `git`, як програму, що запускається при вході, то користувач `git` не зможе здобути нормальний доступ до вашого серверу.
//To use this, specify `git-shell` instead of bash or csh for your user's login shell.
Щоб цим скористатись, задайте `git-shell` замість bash чи csh як оболонку при вході для вашого користувача.
//To do so, you must first add `git-shell` to `/etc/shells` if it's not already there:
Щоб це зробити, треба спочатку додати `git-shell` до `/etc/shells`, якщо його там ще нема:

//$ cat /etc/shells # see if `git-shell` is already in there. If not...
//$ which git-shell # make sure git-shell is installed on your system.
//$ sudo vim /etc/shells # and add the path to git-shell from last command
[source,console]
----
$ cat /etc/shells # see if `git-shell` is already in there. If not...
$ which git-shell # make sure git-shell is installed on your system.
$ sudo vim /etc/shells # and add the path to git-shell from last command
$ cat /etc/shells # перевірте, може `git-shell` вже є у файлі. Якщо ні...
$ which git-shell # переконайтесь, що git-shell присутній на вашій системі.
$ sudo vim /etc/shells # та додайте шлях до git-shell за допомогою останньої команди
----

Now you can edit the shell for a user using `chsh <username>`:
//Now you can edit the shell for a user using `chsh <username>`:
Тепер ви можете відредагувати оболонку для користувача за допомогою `chsh <ім'я користувача>`:

//$ sudo chsh git # and enter the path to git-shell, usually: /usr/bin/git-shell
[source,console]
----
$ sudo chsh git # and enter the path to git-shell, usually: /usr/bin/git-shell
$ sudo chsh git # та введіть шлях до git-shell, зазвичай: /usr/bin/git-shell
----

Now, the `git` user can only use the SSH connection to push and pull Git repositories and can't shell onto the machine.
If you try, you'll see a login rejection like this:
//Now, the `git` user can only use the SSH connection to push and pull Git repositories and can't shell onto the machine.
Тепер користувач `git` може використовувати з'єднання SSH виключно щоб викладати та забирати сховища Ґіт, та не може зайти до машини.
//If you try, you'll see a login rejection like this:
Якщо ви спробуєте, ви побачите відмову від входу, схожу на:

[source,console]
----
Expand All @@ -111,7 +139,11 @@ hint: ~/git-shell-commands should exist and have read and execute access.
Connection to gitserver closed.
----

Now Git network commands will still work just fine but the users won't be able to get a shell.
As the output states, you can also set up a directory in the `git` user's home directory that customizes the `git-shell` command a bit.
For instance, you can restrict the Git commands that the server will accept or you can customize the message that users see if they try to SSH in like that.
Run `git help shell` for more information on customizing the shell.(((git commands, help)))
//Now Git network commands will still work just fine but the users won't be able to get a shell.
Тепер мережеві команди Ґіта продовжать працювати без проблем, проте користувачі не зможуть отримати оболонку.
//As the output states, you can also set up a directory in the `git` user's home directory that customizes the `git-shell` command a bit.
Як і стверджує вивід, ви тепер можете створити теку в домашній теці користувача `git`, що трохи змінити поведінку команду `git-shell`
//For instance, you can restrict the Git commands that the server will accept or you can customize the message that users see if they try to SSH in like that.
Наприклад, ви можете обмежити команди Ґіта, які прийме сервер, або ви можете змінити повідомлення, яке бачать користувачі, якщо вони спробують зайти через SSH.
//Run `git help shell` for more information on customizing the shell.(((git commands, help)))
Виконайте `git help shell` для докладнішої інформації про це.(((git commands, help)))
2 changes: 1 addition & 1 deletion status.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"sections/gitweb.asc": 0,
"sections/hosted.asc": 0,
"sections/protocols.asc": 100,
"sections/setting-up-server.asc": 0,
"sections/setting-up-server.asc": 100,
"sections/smart-http.asc": 0
},
"05-distributed-git": {
Expand Down

0 comments on commit 94f1168

Please sign in to comment.