Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux系统 > » 正文

Linux下基于ssh协议GIT服务器搭建实例

来源: 未知 分享至:

第一:关于SSH的设置

1、  在客户端

[root@ethnicity ~]# ssh-keygen   //生成公匙和密匙

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

af:7a:4c:de:69:7d:5d:4c:74:41:2f:4b:9a:9f:69:08 root@ethnicity

[root@ethnicity ~]# scp .ssh/id_rsa.pub 192.168.1.193:/root  //把自己的公匙上传到服务器

The authenticity of host '192.168.1.193 (192.168.1.193)' can't be established.

RSA key fingerprint is 0a:54:06:f8:28:41:bd:cd:bd:e6:fa:ae:de:56:24:78.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.193' (RSA) to the list of known hosts.

root@192.168.1.193's password:

id_rsa.pub                                    100%  396     0.4KB/s   00:00

2、在服务器端的设置

[root@wanyan ~]# ssh-keygen   //下边不输入任何一直点击确认

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

07:8f:af:6b:15:9c:7a:9b:7c:a8:7e:41:dd:bd:1f:56 root@wanyan

[root@wanyan ~]# cat id_rsa.pub >> .ssh/authorized_keys  //导入客户端的公匙

第二:关于git安装和配置

1、  在服务器端和客户端的公共配置

[root@wanyan ~]# ls git-1.7.7.4.tar.gz

git-1.7.7.4.tar.gz

[root@wanyan ~]# tar zxvf git-1.7.7.4.tar.gz

[root@wanyan ~]# cd git-1.7.7.4

[root@wanyan git-1.7.7.4]# ./configure

[root@wanyan git-1.7.7.4]# make && make install

[root@wanyan git-1.7.7.4]# cp contrib/completion/git-completion.bash ~/.git-completion.bash

[root@wanyan git-1.7.7.4]# vi ~/.bashrc  //加入下句话

source ~/.git-completion.bash

[root@wanyan git-1.7.7.4]# source ~/.bashrc

2、  在服务器端仅有的操作

[root@wanyan ~]# mkdir -p /opt/git/mygit

[root@wanyan mygit]# git --bare init   //创建“仓库“

Initialized empty Git repository in /opt/git/mygit/

3、  在客户端的操作

[root@ethnicity ~]# mkdir /git

[root@ethnicity ~]# cd /git/

[root@ethnicity git]# git init

Initialized empty Git repository in /git/.git/

[root@ethnicity git]# vim README

 

Hello ethnicitybeta!

[root@ethnicity git]# git add .

[root@ethnicity git]# git commit -m "1st commmit"

[master (root-commit) e28450f] 1st commmit

 1 files changed, 1 insertions(+), 0 deletions(-)

 create mode 100644 README

[root@ethnicity git]# git remote add origin 192.168.1.193:/opt/git/mygit  

[root@ethnicity git]# git push origin master   //把自己的修改提交给服务器

Counting objects: 3, done.

Writing objects: 100% (3/3), 221 bytes, done.

Total 3 (delta 0), reused 0 (delta 0)

To 192.168.1.193:/opt/git/mygit

 * [new branch]      master -> master

第三:关于权限的设定

这里设置只有有权限的人可以浏览修改,其他人不可以

[root@wanyan ~]# useradd git

[root@wanyan ~]# vim /etc/passwd

git:x:501:501::/home/git:/bin/bash/git-shell

这样就可以了

 总结:git学习笔记。


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史