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

WBOY
Release: 2016-07-28 08:26:58
Original
1353 people have browsed it

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
Copy after login
3.切换到zph用户 
Copy after login
# su zph
Copy after login

$ cd 
Copy after login

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

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

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"
Copy after login

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

$ vi authorized_keys
Copy after login

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 
Copy after login
10. Verify whether authorized_keys is effective, open windows
$ ssh zph@192.168.1.239
Copy after login

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
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!