[root@localhost ~]# yum install -y git [root@localhost ~]# useradd -s /usr/bin/git-shell git [root@localhost ~]# cd /home/git/ [root@localhost git]# ls [root@localhost git]# mkdir .ssh [root@localhost git]# touch .ssh/authorized_keys [root@localhost git]# chmod 600 .ssh/authorized_keys [root@localhost git]# chown -R git:git .ssh/ [root@localhost git]# vi .ssh/authorizzed_keys 添加客戶端的keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJTjJTm78zW2k2t+5DLUbBJ2G4Ie/P+0EarJZvx0wl8uVvkjx7taOPb7v3a3gQP947egyEHDPnfOiXQ64RCX7jMGlYDvxNjbVXyrgPtTwZIGji61HmgtdXx43JYOkj+uq5fJ/UhI7UgG9Q+n9NkubNxb3KxLyrjoydACAq23uwOqiU20zhXSExeJJvMf3p7iQCXJBF1Gr+SMyVDi0+RNvCsE8FsI6hNvw7PFqjSk1xRdeSRUGKAQ1vPRVPD9Ha8zef5ROr6YYWSfE5xJbR5YoD5xGH+7oKp3p+kG5wndsWuiCPBLwVOrwIb68gKJQl0Mrn1L0BZ+j62hrcnmWVGPtb root@localhost.localdomainistartor
[root@localhost ~]# ssh git@192.168.81.131 ......
[root@localhost git]# mkdir /data/gitroot [root@localhost git]# cd !$ cd /data/gitroot [root@localhost gitroot]# git init --bare sample.git Initialized empty Git repository in /data/gitroot/sample.git/ [root@localhost gitroot]# ll total 4 drwxr-xr-x. 7 root root 4096 Aug 6 10:30 sample.git [root@localhost gitroot]# chown -R git.git sample.git/
[root@localhost ~]# git clone git@192.168.81.131:/data/gitroot/sample.git ......
錯誤git
[root@localhost ~]# ssh git@192.168.81.131 ssh_exchange_identification: read: Connection reset by peer
緣由是.ssh/authorized_keys 寫錯shell
錯誤服務器
[root@localhost ~]# ssh git@192.168.81.131 ssh_exchange_identification: read: Connection reset by peer [root@localhost ~]# ssh 192.168.81.131 ssh_exchange_identification: read: Connection reset by peer [root@localhost ~]# ssh -v 192.168.81.131 OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 51: Applying options for * debug1: Connecting to 192.168.81.131 [192.168.81.131] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type 1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.4 ssh_exchange_identification: read: Connection reset by peer