直接看命令
wget https://Github.com/Git/Git/archive/v2.11.0.tar.gz
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils- MakeMaker 依赖
sudo tar -zxvf v2.11.0.tar.gz 解压
cd v2.11.0
make prefix=/usr/local all 编译 放到/usr/local目录
安装(与上一条路径保持一致)
make prefix=/usr/local install
安装完查看版本 git --version 及位置 whereis git
加入Path 添加/usr/bin/git/bin: 注意结尾是冒号
vim /etc/profile
export PATH=$PATH:$JAVA_HOME/bin:/usr/bin/git/bin:$CATALINA_HOME/bin:$MAVEN_HOME/bin:$NODE_HOME/bin:/usr/local/bin:$RUBY_HOME/bin
source /etc/profile 刷新使其生效
让git不要管Linux与Windows换行符转换
git config --global core.autocrlf false
配置编码 避免中文乱码
git config --global core.quotepath off
git config --global gui.encoding utf-8
nginx安装依赖命令
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
第二步 配置ssh
- 安装完成后对git进行配置,需要确保连接上是你的开源中国的账号,需要命令
git config --global user.name "XXX"
和git config --global user.eamil "邮箱地址"
- 注意每次使用前都要 执行下列代码
[root@izwz9em1ujylnfz25h2u2iz local]# git config --global user.name "bingganlen"
[root@izwz9em1ujylnfz25h2u2iz local]# git config --global user.email "2832269921@qq.com"
配置完成后,需要创建验证的公钥(与windows下相同),每个用户需要独立的公钥来确定。使用命令ssh-key -C '你的邮箱地址' -t rsa
,此时会在用户目录~/.ssh/
下建立相应 的密钥文件
ssh-keygen -t rsa -C "2832269921@qq.com"
ssh-add ~/.ssh/id_rsa
之后使用命令cd ~/.ssh
进入文件夹,使用gedit id_rsa.pub
打开id_rsa.pub
文件。文件里面的内容就是ssh公钥,将其全部复制。打开开源中国网址,选择增加ssh公钥一项,标题的内容随意输入,下面将复制的内容粘贴进去之后就完成了。
-
可以使用命令
ssh -T git@git.oschina.net
来测试是否成功。
安装中需要注意
-
注意在配置的时候使用命令
ssh-keygen -C 'you email address@gmail.com' -t rsa
(注意ssh与-keygen之间没有空格) -
之后在输入完这个命令以后会有
Enter file in which to save the key(/home/haohao/.ssh/id_rsa)
这个输入选项,并不用在意,这个是选择是否在默认地址创建文件还是在新输入的地方创建(新的文件名称),回车就好,就可以在默认的地址创建新的ssh文件
-
进入文件
~/.ssh
文件夹时候,使用命令进入就好,如果从我的电脑里用鼠标找的话可能会找不到,因为这个文件夹.ssh
是个默认隐藏文件夹。所以之找不到并不用担心是电脑的问题,只是隐藏起来了。
[root@izwz9em1ujylnfz25h2u2iz usr]# mkdir gitdown
[root@izwz9em1ujylnfz25h2u2iz usr]# cd local
[root@izwz9em1ujylnfz25h2u2iz local]# git config --global user.name "bingganlen"
[root@izwz9em1ujylnfz25h2u2iz local]# git config --global user.email "2832269921@qq.com"
[root@izwz9em1ujylnfz25h2u2iz local]# ssh-keygen -t rsa -C "2832269921@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
SHA256:gyc/jRpvcJyb4xqc1DUaxE/gusSh83r4mYQURX6MmbI 2832269921@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| .o.o. |
| o B. . |
| o * =oo |
| * * +.. |
| E B.S. |
| . B.*++ |
| ..Oo+o. |
| .o.B=. |
| .o*+o. |
+----[SHA256]-----+
[root@izwz9em1ujylnfz25h2u2iz local]# ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
[root@izwz9em1ujylnfz25h2u2iz local]# cd -
/usr
[root@izwz9em1ujylnfz25h2u2iz usr]# ll
total 124
dr-xr-xr-x. 2 root root 24576 Nov 23 16:53 bin
drwxr-xr-x. 2 root root 4096 Apr 11 2018 etc
drwxr-xr-x 2 root root 4096 Nov 21 20:12 ftpfile
drwxr-xr-x. 2 root root 4096 Apr 11 2018 games
drwxr-xr-x 2 root root 4096 Nov 23 17:05 gitdown
drwxr-xr-x. 47 root root 4096 Nov 23 16:53 include
dr-xr-xr-x. 36 root root 4096 Nov 7 11:45 lib
dr-xr-xr-x. 41 root root 28672 Nov 23 16:53 lib64
drwxr-xr-x. 25 root root 4096 Nov 23 16:53 libexec
drwxr-xr-x. 18 root root 4096 Nov 23 16:54 local
drwxr-xr-x 7 root root 4096 Nov 8 16:52 mysource
dr-xr-xr-x. 2 root root 20480 Nov 21 17:19 sbin
drwxr-xr-x. 87 root root 4096 Nov 23 16:53 share
drwxr-xr-x. 4 root root 4096 Apr 11 2018 src
lrwxrwxrwx 1 root root 10 Nov 7 11:45 tmp -> ../var/tmp
[root@izwz9em1ujylnfz25h2u2iz usr]# cd gitdown/
[root@izwz9em1ujylnfz25h2u2iz gitdown]# ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
[root@izwz9em1ujylnfz25h2u2iz gitdown]# cd ~/.ssh
[root@izwz9em1ujylnfz25h2u2iz .ssh]# ll
total 8
-rw------- 1 root root 0 Oct 29 16:02 authorized_keys
-rw------- 1 root root 1675 Nov 23 17:21 id_rsa
-rw-r--r-- 1 root root 399 Nov 23 17:21 id_rsa.pub
[root@izwz9em1ujylnfz25h2u2iz .ssh]# vi id_rsa
[root@izwz9em1ujylnfz25h2u2iz .ssh]# cd -
/usr/gitdown
[root@izwz9em1ujylnfz25h2u2iz gitdown]# ssh-add Could not open a connection to your authentication agent.
Could not open a connection to your authentication agent.
[root@izwz9em1ujylnfz25h2u2iz gitdown]# ssh-add ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
[root@izwz9em1ujylnfz25h2u2iz gitdown]# cd ~/.ssh
[root@izwz9em1ujylnfz25h2u2iz .ssh]# gedit id_rsa.pub
-bash: gedit: command not found
[root@izwz9em1ujylnfz25h2u2iz .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwNS77QbbM6lBaHSZpeLv3cBG7V4u+IHUcgA5RQluntj+wElJ1LhVtI4+AaG3yefZUDmHDCLuMq6dlepThwawXJQ4GjtOpIZ3ZLVgSKlBK1ncRxw0Col7b3lqIUE9D7ZDaIFlIKhsekvmslEIit0J6+dAoIAbrKRu0Ic/3AAGwowyzkyxNEXa0qw/Yp5JQdUFJvbPOZFUZw4ZDdNQuzSThsKuZPWv9wQAbR3TC6jgZsziH43bni/eMKs8QRUiz8QxFPabyEkTaN0VYMj5987t3oTHn6cqbpLb6kVaekenPKVgIlnQ6j5AviVD0ysxC3N3YkVofBPqTFgp5HnN2PSkZ 2832269921@qq.com
[root@izwz9em1ujylnfz25h2u2iz .ssh]# $ ssh -T git@github.com
-bash: $: command not found
[root@izwz9em1ujylnfz25h2u2iz .ssh]# ssh -T git@github.com
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi bingganlen! You've successfully authenticated, but GitHub does not provide shell access.
[root@izwz9em1ujylnfz25h2u2iz .ssh]#