git 서버 구성
Posted by Albert 1230Day 16Min 48Sec ago [2021-12-07]
작업환경은 Redhat 7.5에서 진행하였다.
1. git 이 설치된 서버라는 전제에서 진행
2. git 사용자 생성
useradd git
su git
passwd // 비번변경
3. makedir ~/githome
cd ~/githome
mkdir project.git
4. git repository 생성
git init --bare ~/githome/project.git/
5. .ssh 생성 및 접근키 등록
mkdir ~/.ssh
(사용자 단에서 관련 rsa key 생성후 .pub 파일을 ~/.ssh 로 넣어준다.
6.키추가 :
cd ~/.ssh
rsa_key.pub >> authorized_keys
7. 사용자 단에서 git clone 하여 repository 생성
$ eval $(ssh-agent -s) //local ssh-agent 시작
$ ssh-add
사용자 pc에서 파일을 git repository 생성을 원하는 위치에 폴더 생성 후
git clone ssh://git@IP주소:/githome/project.git
8. 테스트
clone 한 폴더로 cd 이동후
해당 폴더에 abc.txt 파일 생성
' git add .
' git commit --message "메시지"
' git push origin master
9. 보안상 git shell 막기
' witch git-shell
' chsh git -s /usr/bin/git-shell
' cat /etc/passwd | grep git
참조: https://bamdule.tistory.com/54