From 92392e60e8ad32649be5150d1998a0b8dabada47 Mon Sep 17 00:00:00 2001 From: Awc Cho <423794590@qq.com> Date: Thu, 18 Jun 2015 15:02:28 +0800 Subject: [PATCH] translate04 --- .../sections/generating-ssh-key.asc | 30 +++++----- .../sections/setting-up-server.asc | 56 +++++++++---------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/book/04-git-server/sections/generating-ssh-key.asc b/book/04-git-server/sections/generating-ssh-key.asc index 93015d16..82ab4355 100644 --- a/book/04-git-server/sections/generating-ssh-key.asc +++ b/book/04-git-server/sections/generating-ssh-key.asc @@ -1,13 +1,13 @@ [[_generate_ssh_key]] -=== Generating Your SSH Public Key +=== 生成你的SSH公钥 (((SSH keys))) -That being said, many Git servers authenticate using SSH public keys. -In order to provide a public key, each user in your system must generate one if they don't already have one. -This process is similar across all operating systems. -First, you should check to make sure you don't already have a key. -By default, a user's SSH keys are stored in that user's `~/.ssh` directory. -You can easily check to see if you have a key already by going to that directory and listing the contents: +如人们所说的,许多Git服务器使用SSH公钥来进行认证。 +为了向Git服务器提供一个SSH公钥,每个系统内的用户在没有SSH公钥的情况下必须自行生成。 +这个操作在所有的操作系统上都是相似的。 +首先,你得确认你是否已经拥有了一个密钥。 +一般情况下,用户的SSH公钥储存在 `~/.ssh` 目录内。 +你可以通过下面的操作来快速地确认密钥是否已经存在 [source,console] ---- @@ -17,9 +17,9 @@ authorized_keys2 id_dsa known_hosts config id_dsa.pub ---- -You're looking for a pair of files named something like `id_dsa` or `id_rsa` and a matching file with a `.pub` extension. -The `.pub` file is your public key, and the other file is your private key. -If you don't have these files (or you don't even have a `.ssh` directory), you can create them by running a program called `ssh-keygen`, which is provided with the SSH package on Linux/Mac systems and comes with the MSysGit package on Windows: +你将看见一对名字类似 `id_dsa`(或 `id_rsa`)与其对应的带有 `.pub` 扩展名的密钥。 +带有 `.pub` 扩展名的文件是你的公钥,而另一个则是私钥。 +如果你找不到这些文件(或者你根本没有 `.ssh` 目录),你可以通过运行Linux/Mac的SSH软件包中的 `ssh-keygen` 程序来创建密钥,在Windows上,这个程序包含于MSysGit软件包中。 [source,console] ---- @@ -35,11 +35,11 @@ The key fingerprint is: d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local ---- -First it confirms where you want to save the key (`.ssh/id_rsa`), and then it asks twice for a passphrase, which you can leave empty if you don't want to type a password when you use the key. +首先它会确认密钥的存储位置(默认是 `.ssh/id_rsa`),然后它将让你输入两次密钥口令,如果你不想在使用密钥时使用口令,直接留空即可。 -Now, each user that does this has to send their public key to you or whoever is administrating the Git server (assuming you're using an SSH server setup that requires public keys). -All they have to do is copy the contents of the `.pub` file and e-mail it. -The public keys look something like this: +现在,每个完成了上述操作的用户必须将他们的公钥提交给你或任何管理Git服务器的人(假设你正在使用一个需要公钥来设置SSH服务器) +现在他们需要做的就是将 `.pub` 文件中的内容复制并通过邮件发出。 +公钥看起来是这样的: [source,console] ---- @@ -52,4 +52,4 @@ mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx NrRFi9wrf+M7Q== schacon@mylaptop.local ---- -For a more in-depth tutorial on creating an SSH key on multiple operating systems, see the GitHub guide on SSH keys at https://help.github.com/articles/generating-ssh-keys[]. +想要更深入地了解在多种操作系统中生成SSH密钥的方法,请参阅Github的SSH密钥教程:https://help.github.com/articles/generating-ssh-keys[]. diff --git a/book/04-git-server/sections/setting-up-server.asc b/book/04-git-server/sections/setting-up-server.asc index c4853e6d..71931a4d 100644 --- a/book/04-git-server/sections/setting-up-server.asc +++ b/book/04-git-server/sections/setting-up-server.asc @@ -1,10 +1,10 @@ [[_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. +我们来看看如何在服务器端设置SSH的访问。 +在这个例子中,你将会使用 `authorized_keys` 来对你的用户进行认证。 +当然,我们假设你正在运行的是Ubuntu之类的标准Linux发行版, +首先,创建一个 `git` 用户并在那个用户的用户文件夹下创建 `.ssh` 目录。 [source,console] ---- @@ -15,9 +15,9 @@ $ 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: +接下来,你需要将一些开发者的SSH公钥添加到 `git` 用户的 `authorized_keys` 文件中。 +我们假设你已经将一些受信任的公钥保存到了一个临时目录中。 +同样地,这些公钥看起来是这样的: [source,console] ---- @@ -30,7 +30,7 @@ O7TCUSBdLQlgMVOFq1I2uPWQOkOWQAHukEOmfjy2jctxSDBQ220ymjaNsHT4kgtZg2AYYgPq dAv8JggJICUvax2T9va5 gsg-keypair ---- -You just append them to the `git` user's `authorized_keys` file in its `.ssh` directory: +将公钥添加到 `git` 用户的 `authorized_keys` 文件(在 `ssh` 目录)中: [source,console] ---- @@ -39,7 +39,7 @@ $ cat /tmp/id_rsa.josie.pub >> ~/.ssh/authorized_keys $ cat /tmp/id_rsa.jessica.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))) +现在,你可以通过 `git init` 为他们创建一个空仓库,使用 `--bare` 参数可以在没有工作目录的时候初始化仓库:(((git commands, init, bare))) [source,console] ---- @@ -50,10 +50,10 @@ $ 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): +然后,John, Josie 和 Jessica能够通过将这个仓库设置为remote并创建一个新branch来将他们项目的最初版本push到这个仓库中。 +请注意,每次需要添加一个新项目的时候,用户必须要通过shell连接服务器并创建一个无工作目录的仓库。 +使用 `gitserver` 作为你设置了 `git` 用户并创建了仓库的服务器的主机名。 +如果你正在内网运行这个服务器并在DNS中将 `gitserver` 指向了这个服务器,那么你就可以像这样使用如下命令(假设 `my_project` 已经存在并且其中有文件包含): [source,console] ---- @@ -66,7 +66,7 @@ $ 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: +此时,其他用户能同样简单地 clone 这个仓库并将改动push回来: [source,console] ---- @@ -77,14 +77,14 @@ $ git commit -am 'fix for the README file' $ git push origin master ---- -With this method, you can quickly get a read/write Git server up and running for a handful of developers. +通过这种方法,你可以快速地搭建一个具有读/写权限的 Git 服务器并让他为一群开发者服务。 -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. +请注意,目前所有的用户都可以 `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: +你可以简单地通过一个与 Git 一同安装的名为 `git-shell` 的受限的 shell 来限制 'git' 用户以使其只能进行 Git 活动。 +如果你将此设为 `git` 用户的登陆shell,那么该用户便不能通过有一般的shell访问服务器。 +要使用 `git-shell`,请指定 `git-shell` 为用户的登陆shell,而不是 bash、csh等一般 shell。 +要进行此操作,如果 `/etc/shells` 中不存在 `git-shell`,你必须将 `git-shell` 添加到其中。 [source,console] ---- @@ -93,15 +93,15 @@ $ 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 ---- -Now you can edit the shell for a user using `chsh `: +现在,你可以编辑一个使用 `chsh ` 的用户shell: [source,console] ---- $ sudo chsh git # and enter the path to git-shell, usually: /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: +现在,用户 `git` 只能使用 SSH 连接对 Git 仓库进行 push/pull 操作,而不能通过 shell 控制机器。 +试一试,你会发现如下的登陆拒绝信息: [source,console] ---- @@ -111,7 +111,7 @@ 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))) +现在 Git 的网络命令仍然正常的工作但用户不能通过 shell 操作机器。 +如同输出所显示的,你同样可以建立 `git` 用户的用户目录以稍稍自定义 `git-shell` 命令。 +举个例子,你可以重定向 Git 的命令从而使服务器接受自定义命令,或者,你可以更改用户像上文那样登陆 SSH 时的提示信息。 +要了解更多有关自定义shell的信息,请运行 `git help shell`。(((git commands, help)))