# passwd zph 3. Switch to zph user # su zph$ cd 4. Create a remote warehouse $ git init --bare sample.g"/> # passwd zph 3. Switch to zph user # su zph$ cd 4. Create a remote warehouse $ git init --bare sample.g">

Home  >  Article  >  Backend Development  >  In-depth analysis of git on serverssh, github provides service principles

In-depth analysis of git on serverssh, github provides service principles

WBOY
WBOYOriginal
2016-07-28 08:26:581354browse

1. Install linux and git (192.168.1.239)

2. Create a user zph (let this user provide git on server), and set the password to 12345678

# useradd zph

<pre name="code" class="html"># passwd zph
3.切换到zph用户 
# su zph

$ cd 

4. Create a remote warehouse
$ git init --bare sample.git

5. Under windows (192.168.1.5), open git bash
$ git clone zph@192.168.1.239:/home/zph/sample.git

The terminal will ask you to enter the password. At this time, enter the password of the zph user (12345678)

6. In order to allow users to not have to enter the password every time, in linux Generate the .ssh directory

$ ssh-keygen -t rsa -C "youremail@example.com"

7. Enter .ssh, create a new authorized_keys file
$ cd /home/zph/.ssh/  

$ vi authorized_keys

8. Open the .ssh/id_rsa.pub of the current user in windows, copy the content inside, and paste it into step 7 authorized_keys 9. Change the permissions of the authorized_keys file
$chmod 600 authorized_keys 
10. Verify whether authorized_keys is effective, open windows
$ ssh zph@192.168.1.239

If you do not need to enter a password, it means it is effective

11. Repeat step 5, you no longer need to enter a password

12. If you don’t want zph to log in to the system as an account, you can open /etc/passwd
zph:x:1002:1002::/home/zph:/bin/bash改为zph:x:1002:1002::/home/zph:/sbin/nologin

Additional:

To learn git, please refer to the website https://git-scm.com/book/zh/v2

The above has introduced an in-depth analysis of git on serverssh. Github provides service principles, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn