[root@localhost ~]# wget https://github.com/git/git/archive/v2.24.1.tar.gz
[root@localhost ~]# yum install expat-devel openssl openssl-devel curl-devel -y
[root@localhost ~]# tar zxvf v2.24.1.tar.gz
[root@localhost ~]# cd git-2.24.1/
[root@localhost git-2.24.1]# make prefix=/usr/local/git all
[root@localhost git-2.24.1]# make prefix=/usr/local/git install
[root@localhost git-2.24.1]# cd ..
[root@localhost ~]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
[root@localhost ~]# source /etc/bashrc
[root@localhost ~]# groupadd git
[root@localhost ~]# useradd git -g git
[root@localhost ~]# su - git
[git@localhost ~]$ cat /etc/passwd |grep git
git:x:1002:1002::/home/git:/bin/bash
[root@localhost ~]# su - git
[git@localhost ~]$ cd /home/git/
[git@localhost ~]$ mkdir .ssh
[git@localhost ~]$ chmod 700 .ssh
[git@localhost ~]$ touch .ssh/authorized_keys
[git@localhost ~]$ chmod 600 .ssh/authorized_keys
[git@localhost ~]$ cd ~/.ssh
[git@localhost .ssh]$ ll
总用量 0
-rw-------. 1 git git 0 12月 21 06:55 authorized_keys
[git@localhost .ssh]$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa): authorized_keys
authorized_keys already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in authorized_keys.
Your public key has been saved in authorized_keys.pub.
The key fingerprint is:
SHA256:sBSBC4rSnkFUgZBkNKN1eerEewgAhmXLL2UvxieEHK8 [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|B%*o++o. |
|B=**o .. |
|o==o=+o |
|+ +B=o o |
|..E**o+ S |
| oo++. |
| . |
| |
| |
+----[SHA256]-----+
[git@localhost .ssh]$ ll
总用量 8
-rw-------. 1 git git 1766 12月 21 06:59 authorized_keys
-rw-r--r--. 1 git git 403 12月 21 06:59 authorized_keys.pub
[git@localhost .ssh]$ cat authorized_keys.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkzB8FpT6oVnVhhwp3vd7EsXICgiLwMnlyM8/If9Rh8sfiWKOWbQK2tUsLi9H6SEdpolNyUwdM/+gfkMGYJz2Kjw7IUESJol5WGK+DSNkM2NLF8k/Z2VVSHKE06Crgq+94NTwgGpukZ2o0oTeZjEELMC62RvC9bS+ALv+y7Au87fiOcdeOG2+uR0T1OZIeDSF4zEsnSVAw+PumXptol8oGqiA2jqTDfoeF28tC4JkYviMdTGegSzpDOC4sK0N/+ZZAMznetlXst7iTtIFSbnnFA7pXdovPF8zfxa8hlQjejomYD7mx6i0tSDzRofMwveOdUFKTXgZqEBTc9ZA1KNnT [email protected]
[git@localhost .ssh]$ ssh-add ~/.ssh/authorized_keys
Could not open a connection to your authentication agent.
[git@localhost .ssh]$ eval `ssh-agent -s`
Agent pid 43025
[git@localhost .ssh]$ ssh-add ~/.ssh/authorized_keys
Enter passphrase for /home/git/.ssh/authorized_keys:
Identity added: /home/git/.ssh/authorized_keys (/home/git/.ssh/authorized_keys)
[git@localhost .ssh]$ ssh-add -l
2048 SHA256:sBSBC4rSnkFUgZBkNKN1eerEewgAhmXLL2UvxieEHK8 /home/git/.ssh/authorized_keys (RSA)
[git@localhost ~]$ su
密码:
[root@localhost ~]# vi /etc/passwd
[root@localhost ~]# cat /etc/passwd |grep git
git:x:1002:1002::/home/git:/usr/local/git/bin/git-shell