git centos yum 安装 (服务器端 ,客户端)

简介:   21.git 服务器端安装 centos yum       21.1安装服务器端 yum install -y git git --version 查看安装   21.

 

21.git 服务器端安装 centos yum

 

 

 

21.1安装服务器端

yum install -y git
git --version 查看安装

 

21.2安装客户端

下载 Git for Windows,地址:https://git-for-windows.github.io/

git --version

 

21.3 创建 git 用户

[root@localhost home]# id git 
[root@localhost home]# useradd git
[root@localhost home]# passwd git

 

21.4服务器端创建 Git 仓库

设置 /home/data/git/gittest.git 为 Git 仓库 然后把 Git 仓库的 owner 修改为 git
[root@localhost home]# mkdir -p data/git/gittest.git
[root@localhost home]# git init --bare data/git/gittest.git
Initialized empty Git repository in /home/data/git/gittest.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/

 

21.5客户端 clone 远程仓库

进入 Git Bash 命令行客户端,创建项目地址(设置在 I:\gitrespository)并进入

git clone git@172.23.27.113:/home/data/git/gittest.git

 

The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
RSA key fingerprint is SHA256:Ve6WV/SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ.
Are you sure you want to continue connecting (yes/no)? 
选择 yes: 
Warning: Permanently added '192.168.56.101' (RSA) to the list of known hosts.

 

ssh-keygen -t rsa -C "curiousby@163.com"

 

 

 

 

21.6服务器端 Git 打开 RSA 认证

进入 /etc/ssh 目录,编辑 sshd_config,打开以下三个配置的注释:

 

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
保存并重启 sshd 服务:

[root@localhost ssh]# /etc/rc.d/init.d/sshd restart

 

 

 

 

[root@localhost git]#pwd
/home/git
[root@localhost git]# mkdir .ssh

[root@localhost git]# chown -R git:git .ssh
[root@localhost git]# ll -a
总用量 32
drwx------. 5 git  git  4096 8月  28 20:04 .
drwxr-xr-x. 8 root root 4096 8月  28 19:32 ..
-rw-r--r--. 1 git  git    18 10月 16 2014 .bash_logout
-rw-r--r--. 1 git  git   176 10月 16 2014 .bash_profile
-rw-r--r--. 1 git  git   124 10月 16 2014 .bashrc
drwxr-xr-x. 2 git  git  4096 11月 12 2010 .gnome2
drwxr-xr-x. 4 git  git  4096 5月   8 12:22 .mozilla
drwxr-xr-x. 2 git  git  4096 8月  28 20:08 .ssh

 

 

 

21.7将客户端公钥导入服务器端

/home/git/.ssh/authorized_keys 文件

回到 Git Bash 下,导入文件:

$ ssh git@192.168.56.101 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

 需要输入服务器端 git 用户的密码

 

21.8回到服务器端,查看 .ssh 下是否存在 authorized_keys 文件

修改 .ssh 目录的权限为 700 修改 .ssh/authorized_keys 文件的权限为 600

[root@localhost git]# chmod 700 .ssh
[root@localhost git]# cd .ssh
[root@localhost .ssh]# chmod 600 authorized_keys 

 

 

 

21.9客户端再次 clone 远程仓库

git clone git@172.23.27.113:/home/data/git/gittest.git

 



 

 

21.10 测试上传 到git

 

 

 

 

 

 

 

 

 

 

 

捐助开发者

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。



 
 谢谢您的赞助,我会做的更好!

 

 

 

 

目录
相关文章
|
11天前
|
缓存
yum 如何设置可以将安装的rpm包都缓存下来
【4月更文挑战第17天】yum 如何设置可以将安装的rpm包都缓存下来
33 0
|
1天前
|
Linux 网络安全 数据库
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
|
1天前
|
Linux
CentOS 7 配置yum阿里源 (三步即可)
CentOS 7 配置yum阿里源 (三步即可)
|
5天前
|
Apache 项目管理 数据安全/隐私保护
Windows安装TortoiseSVN客户端结合Cpolar实现公网提交文件到本地服务器
Windows安装TortoiseSVN客户端结合Cpolar实现公网提交文件到本地服务器
|
6天前
|
Unix Shell 开发工具
windows下如何安装git以及IDEA如何配置git
该文指导安装Git 2.15.0版本。首先从Git官网下载最新安装包,双击安装,依次选择Next,同意默认配置,确保勾选添加到环境变量。在配置选项中,选择在cmd中使用Git(第2项),行结束转换选Windows(第1项),终端模拟器选MinTTY(第1项)。安装完成后,通过右键菜单或直接打开Git Bash验证安装成功。最后,配置全局用户名和邮箱,并在IDEA中设置Git路径以完成集成。
|
7天前
|
Shell 数据安全/隐私保护 Docker
如何使用Docker安装FTP服务器?
【4月更文挑战第25天】
13 0
如何使用Docker安装FTP服务器?
|
8天前
|
弹性计算 关系型数据库 MySQL
安装LAMP 环境(yum 版本)
【4月更文挑战第29天】
7 0
|
8天前
|
弹性计算 关系型数据库 Shell
安装 LAMP 环境(yum 版本)
【4月更文挑战第29天】
22 5
|
10天前
|
Ubuntu Linux 网络安全
|
12天前
|
安全 Linux 网络安全
记录_centos搭建ftp服务器
记录_centos搭建ftp服务器
11 0

热门文章

最新文章